4 ms·
I would love to see a small example/snippet illustrating how I'd use this.
by stephanos2k 12y ago
I would love to see a small example/snippet illustrating how I'd use this.
- patrickaljord 12y agoHere are Solomon's slides on the topic. http://www.slideshare.net/shykes/docker-the-road-ahead http://www.slideshare.net/shykes/docker-the-road-ahead
- shykes 12y agoHere's how you would implement basic RPC-style request/response. On the client: var ch libchan.Sender // Send a message, indicate that we want a return channel to be automatically created ret1, err := ch.Send(&libchan.Message{Data: []byte("request 1!"), Ret: libchan.RetPipe}) // Send another message on the same channel ret2, err := ch.Send(&libchan.Message{Data: []byte("request 2!"), Ret: libchan.RetPipe}) // Wait for an answer from the first request. Set flags to zero // to indicate we don't want a nested return channel msg, err := ret1.Receive(0) fmt.Printf("Received answer: %s\n", msg.Data) On the server: var ch libchan.Receiver // Wait for messages in a loop // Set the return channel flag, // to indicate we want to receive nested channels (if any). // Note: we don't send a nested return channel, but we could. for { msg, err := ch.Receive(libchan.Ret) msg.Ret.Send(&libchan.Message{Data: []byte("this is an utterly useless response")}) }
- deleted 12y ago[deleted]
- shurcooL 12y agoI came here to say the same thing. Neither the README nor the examples folder had a very short, basic example. Thanks for the answer (below/above).