Пример #1
0
func (bs *BusStub) call(client *myrpc.RPC, serviceMethod string, args interface{}, reply interface{}) (err error) {
	defer func() {
		log.Printf("BusStub call\nFrom %s(%s) to (%s) with error(%v)\nServiceMethod:%s\nArgs:%+v\nReply:%+v\n",
			bs.selfServer.Name, bs.selfServer.Host, client.GetTargetAddr(), err,
			serviceMethod,
			args,
			reply)
	}()
	if client == nil {
		return errorNullPointer
	}
	return client.Call(serviceMethod, args, reply)
}
Пример #2
0
func (bs *BusStub) makeGo(client *myrpc.RPC, serviceMethod string, args interface{}, reply interface{}) (retErr chan error, err error) {
	defer func() {
		log.Printf("BusStub makeGo\nFrom %s(%s) to (%s) with error(%v)\nServiceMethod:%s\nArgs:%+v\nReply:%+v\n",
			bs.selfServer.Name, bs.selfServer.Host, client.GetTargetAddr(), err,
			serviceMethod,
			args,
			reply)
	}()
	if client == nil {
		err = errorNullPointer
		return
	}
	retErr = client.Go(serviceMethod, args, reply)
	return
}
Пример #3
0
func (bs *BusServer) OnMyRpcConnsBroken(rpcClient *myrpc.RPC, err error) {
	if rpcClient == nil {
		return
	}
	log.Printf("BusServer.OnMyRpcConnsBroken : myrpc conn to %s is broken with err(%v)\n", rpcClient.GetTargetAddr(), err)

	// Todo:optimize searching the right conn
	var foundService *Server
	for _, s := range bs.serviceById {
		if s.RPCClient == rpcClient {
			// found
			foundService = s
		}
	}

	if foundService != nil {
		bs.deleteServer(foundService)
	}
}