From 706ccc9d71b3bd7b0555bf657dc80268b79222df Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Sun, 21 Jun 2015 10:57:28 +0900 Subject: api: change ModPath() return value to Error from stream Error cut useless grpc communication and improve performance simple performance test result. rib.20150617.2000 is taken from http://archive.routeviews.org/ [before] $ time gomrt -i rib.20150617.2000 gomrt -i /vagrant/rib.20150617.2000 45.96s user 171.73s system 86% cpu 4:11.87 total [after] $ time gomrt -i rib.20150617.2000 gomrt -i /vagrant/rib.20150617.2000 11.95s user 76.17s system 74% cpu 1:58.38 total Signed-off-by: ISHIDA Wataru --- api/gobgp.pb.go | 12 +++++++----- api/gobgp.proto | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'api') diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 060aaa68..7d01de14 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -1384,7 +1384,7 @@ func (c *grpcClient) ModPath(ctx context.Context, opts ...grpc.CallOption) (Grpc type Grpc_ModPathClient interface { Send(*ModPathArguments) error - Recv() (*Error, error) + CloseAndRecv() (*Error, error) grpc.ClientStream } @@ -1396,7 +1396,10 @@ func (x *grpcModPathClient) Send(m *ModPathArguments) error { return x.ClientStream.SendMsg(m) } -func (x *grpcModPathClient) Recv() (*Error, error) { +func (x *grpcModPathClient) CloseAndRecv() (*Error, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } m := new(Error) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err @@ -1706,7 +1709,7 @@ func _Grpc_ModPath_Handler(srv interface{}, stream grpc.ServerStream) error { } type Grpc_ModPathServer interface { - Send(*Error) error + SendAndClose(*Error) error Recv() (*ModPathArguments, error) grpc.ServerStream } @@ -1715,7 +1718,7 @@ type grpcModPathServer struct { grpc.ServerStream } -func (x *grpcModPathServer) Send(m *Error) error { +func (x *grpcModPathServer) SendAndClose(m *Error) error { return x.ServerStream.SendMsg(m) } @@ -1888,7 +1891,6 @@ var _Grpc_serviceDesc = grpc.ServiceDesc{ { StreamName: "ModPath", Handler: _Grpc_ModPath_Handler, - ServerStreams: true, ClientStreams: true, }, { diff --git a/api/gobgp.proto b/api/gobgp.proto index b4beb1c2..e54eacca 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -31,7 +31,7 @@ service Grpc { rpc Shutdown(Arguments) returns (Error) {} rpc Enable(Arguments) returns (Error) {} rpc Disable(Arguments) returns (Error) {} - rpc ModPath(stream ModPathArguments) returns (stream Error) {} + rpc ModPath(stream ModPathArguments) returns (Error) {} rpc GetNeighborPolicy(Arguments) returns (ApplyPolicy) {} rpc ModNeighborPolicy(stream PolicyArguments) returns (stream Error) {} rpc GetPolicyRoutePolicies(PolicyArguments) returns (stream PolicyDefinition) {} -- cgit v1.2.3