Пример #1
0
func init() {
	rpc.RegisterSessionMaker(pushMessageID, rpc.NewSessionHandlerFunc(makePushSession))

	d := rpc.Dispatcher()
	d.AddFunc(sendRepoMsg, handleSendRepo)
	d.AddFunc(StartDataMsg, handleStartData)
	d.AddFunc(PutKVMsg, handlePutKV)

	gorpc.RegisterType(&repoTxMsg{})
	gorpc.RegisterType(&DataTxInit{})
	gorpc.RegisterType(&KVMessage{})
}
Пример #2
0
// SendRPC sends a request to a remote DVID.
func SendRPC(addr string, req datastore.Request) error {
	c := gorpc.NewTCPClient(addr)
	c.Start()
	defer c.Stop()

	dc := rpc.Dispatcher().NewFuncClient(c)
	resp, err := dc.Call(commandMsg, req)
	if err != nil {
		return fmt.Errorf("RPC error for %q: %v", req.Command, err)
	}

	reply, ok := resp.(*datastore.Response)
	if !ok {
		return fmt.Errorf("bad response to request %s: %v", req, resp)
	}
	return reply.Write(os.Stdout)
}
Пример #3
0
func init() {
	d := rpc.Dispatcher()
	d.AddFunc(commandMsg, handleCommand)

	gorpc.RegisterType(&datastore.Request{})
}