예제 #1
0
func newMessage(buf []byte) rpccapnp.Message {
	_, s, err := capnp.NewMessage(capnp.SingleSegment(buf))
	if err != nil {
		panic(err)
	}
	m, err := rpccapnp.NewRootMessage(s)
	if err != nil {
		panic(err)
	}
	return m
}
예제 #2
0
func sendMessage(ctx context.Context, t rpc.Transport, f func(rpccapnp.Message) error) error {
	_, s, err := capnp.NewMessage(capnp.SingleSegment(nil))
	m, err := rpccapnp.NewRootMessage(s)
	if err != nil {
		return err
	}
	if err := f(m); err != nil {
		return err
	}
	return t.SendMessage(ctx, m)
}