Applicatioin processes communicate through standard Go channels. The
package also provides simple access to exported remote methods (RPC).
Examples:
1. Send "Hello" from one process to another.
Sending side:
------------------
outch, err := mbxchan.MakeClientChan("mybox")
outch <- []byte("Hello")
...
mbxchan.CloseClientChan(outch)
Receiving side:
--------------------
inch, err := mbxchan.MakeServerChan("mybox", "HTTP")
body, ok <- inch
fmt.Printf("%s\n", string(body))
...
mbxchan.CloseServerChan(inch)
2. Synchronous RPC call to remote method by name "Mul"
type MulStruct struct { A, B int }
Client side:
----------------
rpc := mbxchan.OpenRpcConn("Mul")
args := MulStruct{3, 4}
reply := new(int)
err := rpc.RpcCall(args, reply)
Server side:
----------------
err := mbxchan.PublishRpcMethod("Mul", CalcMul) // CalcMul function
is a user function
3. Asynchronous RPC call to remote method by name "Mul". Asynchronous call
returns pointer to structure:
type rpcCall struct {
Reply interface{}
Error error
Done chan rpcCall
}
Client side:
---------------
rpc := mbxchan.OpenRpcConn("Mul")
args := MulStruct{6, 7}
reply := new(int)
mulCall := rpc.RpcGo(args, reply)
...
replyCall := <-mulCall.Done
The package could be found on: http://bitbucket.org/levarnon/mbx
See also 'mbxchan' link in http://code.google.com/p/go-wiki/wiki/Projects
Comments are welcome
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.