FAQ
I have an RPC endpoint that is simply a way for the client to send the
server some information. There's no return value. However, the rpc
package requires a return value in the signature of the function.... is
there a better option than this?

func (server) SetInfo(info string, _ *struct{}) error {}

That's pretty ugly.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Aliaksandr Valialkin at Jun 11, 2015 at 2:15 pm
    Nate, take a look at https://github.com/valyala/gorpc . With gorpc you can
    write something like the following:

    Server-side code:

    // Set up rpc function handlers.
    d := gorpc.NewDispatcher()
    d.AddFunc("SetInfo", func(info string) {
         // your code here
    })

    // Serve functions set up above on TCP address serverAddr.
    s := gorpc.NewTCPServer(serverAddr, d.NewHandlerFunc())
    if err := s.Serve(); err != nil {
         log.Fatalf("Error in server: %s", err)
    }

    Client-side code:

    // Globally-visible rpc client.
    var dc *gorpc.DispatcherClient

    func main() {
         // Initialize rpc client connected to TCP address serverAddr.
         c := gorcp.NewTCPClient(serverAddr)
         c.Start()
         defer c.Stop()
         dc = gorpc.NewDispatcher().NewFuncClient(c)

         // Other initialization code here.
    }

    // Use globally-visible rpc client throughout your code from concurrently
    running goroutines.
    for i := 0; i < 100; i++ {
         dc.Send("SetInfo", fmt.Sprintf("info %d", i))
    }

    On Wednesday, June 10, 2015 at 12:47:35 PM UTC+3, Nate Finch wrote:

    I have an RPC endpoint that is simply a way for the client to send the
    server some information. There's no return value. However, the rpc
    package requires a return value in the signature of the function.... is
    there a better option than this?

    func (server) SetInfo(info string, _ *struct{}) error {}

    That's pretty ugly.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 10, '15 at 9:47a
activeJun 11, '15 at 2:15p
posts2
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase