From 01865d3a4efed786e5492ffc848f8c299ee89596 Mon Sep 17 00:00:00 2001 From: Niranjan Mahabaleshwar <109181518+nmahabaleshwar@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:48:45 -0800 Subject: [PATCH] Update the text with updated behavior and generate the go bindings --- acctz/acctz.pb.go | 12 ++++++------ acctz/acctz.proto | 6 ++++-- acctz/acctz_grpc.pb.go | 35 +++++++++++++++-------------------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/acctz/acctz.pb.go b/acctz/acctz.pb.go index 51c35d8..324ab5f 100755 --- a/acctz/acctz.pb.go +++ b/acctz/acctz.pb.go @@ -1191,16 +1191,16 @@ var file_github_com_openconfig_gnsi_acctz_acctz_proto_rawDesc = []byte{ 0x74, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x32, 0x5b, 0x0a, 0x05, 0x41, - 0x63, 0x63, 0x74, 0x7a, 0x12, 0x52, 0x0a, 0x0f, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x75, + 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x32, 0x59, 0x0a, 0x05, 0x41, + 0x63, 0x63, 0x74, 0x7a, 0x12, 0x50, 0x0a, 0x0f, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6e, 0x73, 0x69, 0x2e, 0x61, 0x63, 0x63, 0x74, 0x7a, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6e, 0x73, 0x69, 0x2e, 0x61, 0x63, 0x63, 0x74, 0x7a, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x67, 0x6e, 0x73, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x74, 0x7a, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x67, 0x6e, 0x73, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x74, 0x7a, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/acctz/acctz.proto b/acctz/acctz.proto index fb06972..b10dfb8 100644 --- a/acctz/acctz.proto +++ b/acctz/acctz.proto @@ -53,8 +53,10 @@ service Acctz { // // A RecordRequest contains a timestamp indicating the last message // received. The Collector's expectation is that all messages after the - // timestamp will be streamed. If this results in no records to send, the - // server should return an OK error and zero records. + // timestamp will be streamed. If this results in no records to be sent, + // because either the history is empty or no new accounting events occured + // after the requested timestamp, the server will be silent until new + // records are created. // // Any history for replay of records or size of the history is subject to // implementation support and may or may not be configurable. The history diff --git a/acctz/acctz_grpc.pb.go b/acctz/acctz_grpc.pb.go index 69cf9b0..dc0e936 100755 --- a/acctz/acctz_grpc.pb.go +++ b/acctz/acctz_grpc.pb.go @@ -22,7 +22,7 @@ const _ = grpc.SupportPackageIsVersion7 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AcctzClient interface { - RecordSubscribe(ctx context.Context, opts ...grpc.CallOption) (Acctz_RecordSubscribeClient, error) + RecordSubscribe(ctx context.Context, in *RecordRequest, opts ...grpc.CallOption) (Acctz_RecordSubscribeClient, error) } type acctzClient struct { @@ -33,17 +33,22 @@ func NewAcctzClient(cc grpc.ClientConnInterface) AcctzClient { return &acctzClient{cc} } -func (c *acctzClient) RecordSubscribe(ctx context.Context, opts ...grpc.CallOption) (Acctz_RecordSubscribeClient, error) { +func (c *acctzClient) RecordSubscribe(ctx context.Context, in *RecordRequest, opts ...grpc.CallOption) (Acctz_RecordSubscribeClient, error) { stream, err := c.cc.NewStream(ctx, &Acctz_ServiceDesc.Streams[0], "/gnsi.acctz.v1.Acctz/RecordSubscribe", opts...) if err != nil { return nil, err } x := &acctzRecordSubscribeClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } return x, nil } type Acctz_RecordSubscribeClient interface { - Send(*RecordRequest) error Recv() (*RecordResponse, error) grpc.ClientStream } @@ -52,10 +57,6 @@ type acctzRecordSubscribeClient struct { grpc.ClientStream } -func (x *acctzRecordSubscribeClient) Send(m *RecordRequest) error { - return x.ClientStream.SendMsg(m) -} - func (x *acctzRecordSubscribeClient) Recv() (*RecordResponse, error) { m := new(RecordResponse) if err := x.ClientStream.RecvMsg(m); err != nil { @@ -68,7 +69,7 @@ func (x *acctzRecordSubscribeClient) Recv() (*RecordResponse, error) { // All implementations must embed UnimplementedAcctzServer // for forward compatibility type AcctzServer interface { - RecordSubscribe(Acctz_RecordSubscribeServer) error + RecordSubscribe(*RecordRequest, Acctz_RecordSubscribeServer) error mustEmbedUnimplementedAcctzServer() } @@ -76,7 +77,7 @@ type AcctzServer interface { type UnimplementedAcctzServer struct { } -func (UnimplementedAcctzServer) RecordSubscribe(Acctz_RecordSubscribeServer) error { +func (UnimplementedAcctzServer) RecordSubscribe(*RecordRequest, Acctz_RecordSubscribeServer) error { return status.Errorf(codes.Unimplemented, "method RecordSubscribe not implemented") } func (UnimplementedAcctzServer) mustEmbedUnimplementedAcctzServer() {} @@ -93,12 +94,15 @@ func RegisterAcctzServer(s grpc.ServiceRegistrar, srv AcctzServer) { } func _Acctz_RecordSubscribe_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(AcctzServer).RecordSubscribe(&acctzRecordSubscribeServer{stream}) + m := new(RecordRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(AcctzServer).RecordSubscribe(m, &acctzRecordSubscribeServer{stream}) } type Acctz_RecordSubscribeServer interface { Send(*RecordResponse) error - Recv() (*RecordRequest, error) grpc.ServerStream } @@ -110,14 +114,6 @@ func (x *acctzRecordSubscribeServer) Send(m *RecordResponse) error { return x.ServerStream.SendMsg(m) } -func (x *acctzRecordSubscribeServer) Recv() (*RecordRequest, error) { - m := new(RecordRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - // Acctz_ServiceDesc is the grpc.ServiceDesc for Acctz service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -130,7 +126,6 @@ var Acctz_ServiceDesc = grpc.ServiceDesc{ StreamName: "RecordSubscribe", Handler: _Acctz_RecordSubscribe_Handler, ServerStreams: true, - ClientStreams: true, }, }, Metadata: "github.com/openconfig/gnsi/acctz/acctz.proto",