From 23935c7dc33e517bdca28a46aecf4570cd847a4c Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 29 Jul 2024 16:42:10 -0700 Subject: [PATCH 1/6] Implement MarshalYAML on RoomConfiguration and related types --- livekit/types.go | 30 +++++++++++++++++++ livekit/types_test.go | 68 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/livekit/types.go b/livekit/types.go index a07cfbe87..ae37a0b62 100644 --- a/livekit/types.go +++ b/livekit/types.go @@ -16,6 +16,7 @@ package livekit import ( "github.com/bufbuild/protoyaml-go" + proto "google.golang.org/protobuf/proto" "gopkg.in/yaml.v3" ) @@ -73,6 +74,10 @@ func (r *RoomConfiguration) UnmarshalYAML(value *yaml.Node) error { return protoyaml.Unmarshal(str, r) } +func (r *RoomConfiguration) MarshalYAML() (interface{}, error) { + return marshalProto(r) +} + func (r *RoomEgress) UnmarshalYAML(value *yaml.Node) error { // Marshall the Node back to yaml to pass it to the protobuf specific unmarshaller str, err := yaml.Marshal(value) @@ -83,6 +88,10 @@ func (r *RoomEgress) UnmarshalYAML(value *yaml.Node) error { return protoyaml.Unmarshal(str, r) } +func (r *RoomEgress) MarshalYAML() (interface{}, error) { + return marshalProto(r) +} + func (r *RoomAgent) UnmarshalYAML(value *yaml.Node) error { // Marshall the Node back to yaml to pass it to the protobuf specific unmarshaller str, err := yaml.Marshal(value) @@ -92,3 +101,24 @@ func (r *RoomAgent) UnmarshalYAML(value *yaml.Node) error { return protoyaml.Unmarshal(str, r) } + +func (r *RoomAgent) MarshalYAML() (interface{}, error) { + return marshalProto(r) +} + +func marshalProto(o proto.Message) (map[string]interface{}, error) { + // Marshall the Node back to yaml to pass it to the protobuf specific unmarshaller + str, err := protoyaml.MarshalOptions{UseProtoNames: true}.Marshal(o) + if err != nil { + return nil, err + } + + m := make(map[string]interface{}) + + err = yaml.Unmarshal(str, &m) + if err != nil { + return nil, err + } + + return m, nil +} diff --git a/livekit/types_test.go b/livekit/types_test.go index c0984732d..5d1257188 100644 --- a/livekit/types_test.go +++ b/livekit/types_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" + proto "google.golang.org/protobuf/proto" "gopkg.in/yaml.v3" ) @@ -39,6 +40,38 @@ a: } +func TestMarshallRoomConfiguration(t *testing.T) { + r := &RoomConfiguration{ + Name: "name", + MaxParticipants: 42, + EmptyTimeout: 12, + DepartureTimeout: 13, + MinPlayoutDelay: 14, + MaxPlayoutDelay: 15, + Egress: &RoomEgress{ + Room: &RoomCompositeEgressRequest{ + AudioOnly: true, + RoomName: "room name", + }, + }, + Agent: &RoomAgent{ + Dispatches: []*RoomAgentDispatch{ + &RoomAgentDispatch{ + AgentName: "agent name", + }, + }, + }, + } + + b, err := yaml.Marshal(r) + require.NoError(t, err) + + var ur RoomConfiguration + err = yaml.Unmarshal(b, &ur) + require.NoError(t, err) + require.True(t, proto.Equal(r, &ur)) +} + func TestUnmarshallRoomEgress(t *testing.T) { y := ` a: @@ -67,6 +100,23 @@ b: require.Equal(t, "key", re.Participant.FileOutputs[0].Output.(*EncodedFileOutput_S3).S3.AccessKey) } +func TestMarshallRoomEgress(t *testing.T) { + e := &RoomEgress{ + Room: &RoomCompositeEgressRequest{ + AudioOnly: true, + RoomName: "room name", + }, + } + + b, err := yaml.Marshal(e) + require.NoError(t, err) + + var ue RoomEgress + err = yaml.Unmarshal(b, &ue) + require.NoError(t, err) + require.True(t, proto.Equal(e, &ue)) +} + func TestUnmarshallRoomAgent(t *testing.T) { y := ` a: @@ -87,3 +137,21 @@ a: require.Equal(t, "ag", re.Dispatches[1].AgentName) require.Equal(t, "mm", re.Dispatches[1].Metadata) } + +func TestMarshallRoomAgent(t *testing.T) { + a := &RoomAgent{ + Dispatches: []*RoomAgentDispatch{ + &RoomAgentDispatch{ + AgentName: "agent name", + }, + }, + } + + b, err := yaml.Marshal(a) + require.NoError(t, err) + + var ua RoomAgent + err = yaml.Unmarshal(b, &ua) + require.NoError(t, err) + require.True(t, proto.Equal(a, &ua)) +} From 113552d5660a3299d6d7bb5bad6db511f3d19fff Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:43:14 +0000 Subject: [PATCH 2/6] generated protobuf --- infra/link_grpc.pb.go | 69 +++---- livekit/livekit_agent_dispatch_grpc.pb.go | 25 ++- rpc/analytics_grpc.pb.go | 208 +++++----------------- 3 files changed, 94 insertions(+), 208 deletions(-) diff --git a/infra/link_grpc.pb.go b/infra/link_grpc.pb.go index cd17cd1fa..281cec953 100644 --- a/infra/link_grpc.pb.go +++ b/infra/link_grpc.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.4.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v4.23.4 // source: infra/link.proto @@ -29,8 +29,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( Link_WatchLocalLinks_FullMethodName = "/rpc.Link/WatchLocalLinks" @@ -41,7 +41,7 @@ const ( // // 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 LinkClient interface { - WatchLocalLinks(ctx context.Context, in *WatchLocalLinksRequest, opts ...grpc.CallOption) (Link_WatchLocalLinksClient, error) + WatchLocalLinks(ctx context.Context, in *WatchLocalLinksRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WatchLocalLinksResponse], error) SimulateLinkState(ctx context.Context, in *SimulateLinkStateRequest, opts ...grpc.CallOption) (*SimulateLinkStateResponse, error) } @@ -53,13 +53,13 @@ func NewLinkClient(cc grpc.ClientConnInterface) LinkClient { return &linkClient{cc} } -func (c *linkClient) WatchLocalLinks(ctx context.Context, in *WatchLocalLinksRequest, opts ...grpc.CallOption) (Link_WatchLocalLinksClient, error) { +func (c *linkClient) WatchLocalLinks(ctx context.Context, in *WatchLocalLinksRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WatchLocalLinksResponse], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &Link_ServiceDesc.Streams[0], Link_WatchLocalLinks_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &linkWatchLocalLinksClient{ClientStream: stream} + x := &grpc.GenericClientStream[WatchLocalLinksRequest, WatchLocalLinksResponse]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -69,22 +69,8 @@ func (c *linkClient) WatchLocalLinks(ctx context.Context, in *WatchLocalLinksReq return x, nil } -type Link_WatchLocalLinksClient interface { - Recv() (*WatchLocalLinksResponse, error) - grpc.ClientStream -} - -type linkWatchLocalLinksClient struct { - grpc.ClientStream -} - -func (x *linkWatchLocalLinksClient) Recv() (*WatchLocalLinksResponse, error) { - m := new(WatchLocalLinksResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Link_WatchLocalLinksClient = grpc.ServerStreamingClient[WatchLocalLinksResponse] func (c *linkClient) SimulateLinkState(ctx context.Context, in *SimulateLinkStateRequest, opts ...grpc.CallOption) (*SimulateLinkStateResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) @@ -98,24 +84,28 @@ func (c *linkClient) SimulateLinkState(ctx context.Context, in *SimulateLinkStat // LinkServer is the server API for Link service. // All implementations must embed UnimplementedLinkServer -// for forward compatibility +// for forward compatibility. type LinkServer interface { - WatchLocalLinks(*WatchLocalLinksRequest, Link_WatchLocalLinksServer) error + WatchLocalLinks(*WatchLocalLinksRequest, grpc.ServerStreamingServer[WatchLocalLinksResponse]) error SimulateLinkState(context.Context, *SimulateLinkStateRequest) (*SimulateLinkStateResponse, error) mustEmbedUnimplementedLinkServer() } -// UnimplementedLinkServer must be embedded to have forward compatible implementations. -type UnimplementedLinkServer struct { -} +// UnimplementedLinkServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedLinkServer struct{} -func (UnimplementedLinkServer) WatchLocalLinks(*WatchLocalLinksRequest, Link_WatchLocalLinksServer) error { +func (UnimplementedLinkServer) WatchLocalLinks(*WatchLocalLinksRequest, grpc.ServerStreamingServer[WatchLocalLinksResponse]) error { return status.Errorf(codes.Unimplemented, "method WatchLocalLinks not implemented") } func (UnimplementedLinkServer) SimulateLinkState(context.Context, *SimulateLinkStateRequest) (*SimulateLinkStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SimulateLinkState not implemented") } func (UnimplementedLinkServer) mustEmbedUnimplementedLinkServer() {} +func (UnimplementedLinkServer) testEmbeddedByValue() {} // UnsafeLinkServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to LinkServer will @@ -125,6 +115,13 @@ type UnsafeLinkServer interface { } func RegisterLinkServer(s grpc.ServiceRegistrar, srv LinkServer) { + // If the following call pancis, it indicates UnimplementedLinkServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Link_ServiceDesc, srv) } @@ -133,21 +130,11 @@ func _Link_WatchLocalLinks_Handler(srv interface{}, stream grpc.ServerStream) er if err := stream.RecvMsg(m); err != nil { return err } - return srv.(LinkServer).WatchLocalLinks(m, &linkWatchLocalLinksServer{ServerStream: stream}) -} - -type Link_WatchLocalLinksServer interface { - Send(*WatchLocalLinksResponse) error - grpc.ServerStream + return srv.(LinkServer).WatchLocalLinks(m, &grpc.GenericServerStream[WatchLocalLinksRequest, WatchLocalLinksResponse]{ServerStream: stream}) } -type linkWatchLocalLinksServer struct { - grpc.ServerStream -} - -func (x *linkWatchLocalLinksServer) Send(m *WatchLocalLinksResponse) error { - return x.ServerStream.SendMsg(m) -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type Link_WatchLocalLinksServer = grpc.ServerStreamingServer[WatchLocalLinksResponse] func _Link_SimulateLinkState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SimulateLinkStateRequest) diff --git a/livekit/livekit_agent_dispatch_grpc.pb.go b/livekit/livekit_agent_dispatch_grpc.pb.go index 150f66c25..ef00f55f0 100644 --- a/livekit/livekit_agent_dispatch_grpc.pb.go +++ b/livekit/livekit_agent_dispatch_grpc.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.4.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v4.23.4 // source: livekit_agent_dispatch.proto @@ -29,8 +29,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( AgentDispatchService_CreateDispatch_FullMethodName = "/livekit.AgentDispatchService/CreateDispatch" @@ -87,7 +87,7 @@ func (c *agentDispatchServiceClient) ListDispatch(ctx context.Context, in *ListA // AgentDispatchServiceServer is the server API for AgentDispatchService service. // All implementations must embed UnimplementedAgentDispatchServiceServer -// for forward compatibility +// for forward compatibility. type AgentDispatchServiceServer interface { CreateDispatch(context.Context, *CreateAgentDispatchRequest) (*AgentDispatch, error) DeleteDispatch(context.Context, *DeleteAgentDispatchRequest) (*AgentDispatch, error) @@ -95,9 +95,12 @@ type AgentDispatchServiceServer interface { mustEmbedUnimplementedAgentDispatchServiceServer() } -// UnimplementedAgentDispatchServiceServer must be embedded to have forward compatible implementations. -type UnimplementedAgentDispatchServiceServer struct { -} +// UnimplementedAgentDispatchServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAgentDispatchServiceServer struct{} func (UnimplementedAgentDispatchServiceServer) CreateDispatch(context.Context, *CreateAgentDispatchRequest) (*AgentDispatch, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateDispatch not implemented") @@ -109,6 +112,7 @@ func (UnimplementedAgentDispatchServiceServer) ListDispatch(context.Context, *Li return nil, status.Errorf(codes.Unimplemented, "method ListDispatch not implemented") } func (UnimplementedAgentDispatchServiceServer) mustEmbedUnimplementedAgentDispatchServiceServer() {} +func (UnimplementedAgentDispatchServiceServer) testEmbeddedByValue() {} // UnsafeAgentDispatchServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AgentDispatchServiceServer will @@ -118,6 +122,13 @@ type UnsafeAgentDispatchServiceServer interface { } func RegisterAgentDispatchServiceServer(s grpc.ServiceRegistrar, srv AgentDispatchServiceServer) { + // If the following call pancis, it indicates UnimplementedAgentDispatchServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&AgentDispatchService_ServiceDesc, srv) } diff --git a/rpc/analytics_grpc.pb.go b/rpc/analytics_grpc.pb.go index ac9fe3c6d..6217bb431 100644 --- a/rpc/analytics_grpc.pb.go +++ b/rpc/analytics_grpc.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.4.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v4.23.4 // source: rpc/analytics.proto @@ -31,8 +31,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( AnalyticsRecorderService_IngestStats_FullMethodName = "/livekit.AnalyticsRecorderService/IngestStats" @@ -44,9 +44,9 @@ const ( // // 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 AnalyticsRecorderServiceClient interface { - IngestStats(ctx context.Context, opts ...grpc.CallOption) (AnalyticsRecorderService_IngestStatsClient, error) - IngestEvents(ctx context.Context, opts ...grpc.CallOption) (AnalyticsRecorderService_IngestEventsClient, error) - IngestNodeRoomStates(ctx context.Context, opts ...grpc.CallOption) (AnalyticsRecorderService_IngestNodeRoomStatesClient, error) + IngestStats(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[livekit.AnalyticsStats, emptypb.Empty], error) + IngestEvents(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[livekit.AnalyticsEvents, emptypb.Empty], error) + IngestNodeRoomStates(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[livekit.AnalyticsNodeRooms, emptypb.Empty], error) } type analyticsRecorderServiceClient struct { @@ -57,136 +57,74 @@ func NewAnalyticsRecorderServiceClient(cc grpc.ClientConnInterface) AnalyticsRec return &analyticsRecorderServiceClient{cc} } -func (c *analyticsRecorderServiceClient) IngestStats(ctx context.Context, opts ...grpc.CallOption) (AnalyticsRecorderService_IngestStatsClient, error) { +func (c *analyticsRecorderServiceClient) IngestStats(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[livekit.AnalyticsStats, emptypb.Empty], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &AnalyticsRecorderService_ServiceDesc.Streams[0], AnalyticsRecorderService_IngestStats_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &analyticsRecorderServiceIngestStatsClient{ClientStream: stream} + x := &grpc.GenericClientStream[livekit.AnalyticsStats, emptypb.Empty]{ClientStream: stream} return x, nil } -type AnalyticsRecorderService_IngestStatsClient interface { - Send(*livekit.AnalyticsStats) error - CloseAndRecv() (*emptypb.Empty, error) - grpc.ClientStream -} - -type analyticsRecorderServiceIngestStatsClient struct { - grpc.ClientStream -} - -func (x *analyticsRecorderServiceIngestStatsClient) Send(m *livekit.AnalyticsStats) error { - return x.ClientStream.SendMsg(m) -} - -func (x *analyticsRecorderServiceIngestStatsClient) CloseAndRecv() (*emptypb.Empty, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(emptypb.Empty) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type AnalyticsRecorderService_IngestStatsClient = grpc.ClientStreamingClient[livekit.AnalyticsStats, emptypb.Empty] -func (c *analyticsRecorderServiceClient) IngestEvents(ctx context.Context, opts ...grpc.CallOption) (AnalyticsRecorderService_IngestEventsClient, error) { +func (c *analyticsRecorderServiceClient) IngestEvents(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[livekit.AnalyticsEvents, emptypb.Empty], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &AnalyticsRecorderService_ServiceDesc.Streams[1], AnalyticsRecorderService_IngestEvents_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &analyticsRecorderServiceIngestEventsClient{ClientStream: stream} + x := &grpc.GenericClientStream[livekit.AnalyticsEvents, emptypb.Empty]{ClientStream: stream} return x, nil } -type AnalyticsRecorderService_IngestEventsClient interface { - Send(*livekit.AnalyticsEvents) error - CloseAndRecv() (*emptypb.Empty, error) - grpc.ClientStream -} - -type analyticsRecorderServiceIngestEventsClient struct { - grpc.ClientStream -} - -func (x *analyticsRecorderServiceIngestEventsClient) Send(m *livekit.AnalyticsEvents) error { - return x.ClientStream.SendMsg(m) -} - -func (x *analyticsRecorderServiceIngestEventsClient) CloseAndRecv() (*emptypb.Empty, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(emptypb.Empty) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type AnalyticsRecorderService_IngestEventsClient = grpc.ClientStreamingClient[livekit.AnalyticsEvents, emptypb.Empty] -func (c *analyticsRecorderServiceClient) IngestNodeRoomStates(ctx context.Context, opts ...grpc.CallOption) (AnalyticsRecorderService_IngestNodeRoomStatesClient, error) { +func (c *analyticsRecorderServiceClient) IngestNodeRoomStates(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[livekit.AnalyticsNodeRooms, emptypb.Empty], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &AnalyticsRecorderService_ServiceDesc.Streams[2], AnalyticsRecorderService_IngestNodeRoomStates_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &analyticsRecorderServiceIngestNodeRoomStatesClient{ClientStream: stream} + x := &grpc.GenericClientStream[livekit.AnalyticsNodeRooms, emptypb.Empty]{ClientStream: stream} return x, nil } -type AnalyticsRecorderService_IngestNodeRoomStatesClient interface { - Send(*livekit.AnalyticsNodeRooms) error - CloseAndRecv() (*emptypb.Empty, error) - grpc.ClientStream -} - -type analyticsRecorderServiceIngestNodeRoomStatesClient struct { - grpc.ClientStream -} - -func (x *analyticsRecorderServiceIngestNodeRoomStatesClient) Send(m *livekit.AnalyticsNodeRooms) error { - return x.ClientStream.SendMsg(m) -} - -func (x *analyticsRecorderServiceIngestNodeRoomStatesClient) CloseAndRecv() (*emptypb.Empty, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(emptypb.Empty) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type AnalyticsRecorderService_IngestNodeRoomStatesClient = grpc.ClientStreamingClient[livekit.AnalyticsNodeRooms, emptypb.Empty] // AnalyticsRecorderServiceServer is the server API for AnalyticsRecorderService service. // All implementations must embed UnimplementedAnalyticsRecorderServiceServer -// for forward compatibility +// for forward compatibility. type AnalyticsRecorderServiceServer interface { - IngestStats(AnalyticsRecorderService_IngestStatsServer) error - IngestEvents(AnalyticsRecorderService_IngestEventsServer) error - IngestNodeRoomStates(AnalyticsRecorderService_IngestNodeRoomStatesServer) error + IngestStats(grpc.ClientStreamingServer[livekit.AnalyticsStats, emptypb.Empty]) error + IngestEvents(grpc.ClientStreamingServer[livekit.AnalyticsEvents, emptypb.Empty]) error + IngestNodeRoomStates(grpc.ClientStreamingServer[livekit.AnalyticsNodeRooms, emptypb.Empty]) error mustEmbedUnimplementedAnalyticsRecorderServiceServer() } -// UnimplementedAnalyticsRecorderServiceServer must be embedded to have forward compatible implementations. -type UnimplementedAnalyticsRecorderServiceServer struct { -} +// UnimplementedAnalyticsRecorderServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAnalyticsRecorderServiceServer struct{} -func (UnimplementedAnalyticsRecorderServiceServer) IngestStats(AnalyticsRecorderService_IngestStatsServer) error { +func (UnimplementedAnalyticsRecorderServiceServer) IngestStats(grpc.ClientStreamingServer[livekit.AnalyticsStats, emptypb.Empty]) error { return status.Errorf(codes.Unimplemented, "method IngestStats not implemented") } -func (UnimplementedAnalyticsRecorderServiceServer) IngestEvents(AnalyticsRecorderService_IngestEventsServer) error { +func (UnimplementedAnalyticsRecorderServiceServer) IngestEvents(grpc.ClientStreamingServer[livekit.AnalyticsEvents, emptypb.Empty]) error { return status.Errorf(codes.Unimplemented, "method IngestEvents not implemented") } -func (UnimplementedAnalyticsRecorderServiceServer) IngestNodeRoomStates(AnalyticsRecorderService_IngestNodeRoomStatesServer) error { +func (UnimplementedAnalyticsRecorderServiceServer) IngestNodeRoomStates(grpc.ClientStreamingServer[livekit.AnalyticsNodeRooms, emptypb.Empty]) error { return status.Errorf(codes.Unimplemented, "method IngestNodeRoomStates not implemented") } func (UnimplementedAnalyticsRecorderServiceServer) mustEmbedUnimplementedAnalyticsRecorderServiceServer() { } +func (UnimplementedAnalyticsRecorderServiceServer) testEmbeddedByValue() {} // UnsafeAnalyticsRecorderServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AnalyticsRecorderServiceServer will @@ -196,86 +134,36 @@ type UnsafeAnalyticsRecorderServiceServer interface { } func RegisterAnalyticsRecorderServiceServer(s grpc.ServiceRegistrar, srv AnalyticsRecorderServiceServer) { + // If the following call pancis, it indicates UnimplementedAnalyticsRecorderServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&AnalyticsRecorderService_ServiceDesc, srv) } func _AnalyticsRecorderService_IngestStats_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(AnalyticsRecorderServiceServer).IngestStats(&analyticsRecorderServiceIngestStatsServer{ServerStream: stream}) -} - -type AnalyticsRecorderService_IngestStatsServer interface { - SendAndClose(*emptypb.Empty) error - Recv() (*livekit.AnalyticsStats, error) - grpc.ServerStream -} - -type analyticsRecorderServiceIngestStatsServer struct { - grpc.ServerStream + return srv.(AnalyticsRecorderServiceServer).IngestStats(&grpc.GenericServerStream[livekit.AnalyticsStats, emptypb.Empty]{ServerStream: stream}) } -func (x *analyticsRecorderServiceIngestStatsServer) SendAndClose(m *emptypb.Empty) error { - return x.ServerStream.SendMsg(m) -} - -func (x *analyticsRecorderServiceIngestStatsServer) Recv() (*livekit.AnalyticsStats, error) { - m := new(livekit.AnalyticsStats) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type AnalyticsRecorderService_IngestStatsServer = grpc.ClientStreamingServer[livekit.AnalyticsStats, emptypb.Empty] func _AnalyticsRecorderService_IngestEvents_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(AnalyticsRecorderServiceServer).IngestEvents(&analyticsRecorderServiceIngestEventsServer{ServerStream: stream}) -} - -type AnalyticsRecorderService_IngestEventsServer interface { - SendAndClose(*emptypb.Empty) error - Recv() (*livekit.AnalyticsEvents, error) - grpc.ServerStream + return srv.(AnalyticsRecorderServiceServer).IngestEvents(&grpc.GenericServerStream[livekit.AnalyticsEvents, emptypb.Empty]{ServerStream: stream}) } -type analyticsRecorderServiceIngestEventsServer struct { - grpc.ServerStream -} - -func (x *analyticsRecorderServiceIngestEventsServer) SendAndClose(m *emptypb.Empty) error { - return x.ServerStream.SendMsg(m) -} - -func (x *analyticsRecorderServiceIngestEventsServer) Recv() (*livekit.AnalyticsEvents, error) { - m := new(livekit.AnalyticsEvents) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type AnalyticsRecorderService_IngestEventsServer = grpc.ClientStreamingServer[livekit.AnalyticsEvents, emptypb.Empty] func _AnalyticsRecorderService_IngestNodeRoomStates_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(AnalyticsRecorderServiceServer).IngestNodeRoomStates(&analyticsRecorderServiceIngestNodeRoomStatesServer{ServerStream: stream}) -} - -type AnalyticsRecorderService_IngestNodeRoomStatesServer interface { - SendAndClose(*emptypb.Empty) error - Recv() (*livekit.AnalyticsNodeRooms, error) - grpc.ServerStream + return srv.(AnalyticsRecorderServiceServer).IngestNodeRoomStates(&grpc.GenericServerStream[livekit.AnalyticsNodeRooms, emptypb.Empty]{ServerStream: stream}) } -type analyticsRecorderServiceIngestNodeRoomStatesServer struct { - grpc.ServerStream -} - -func (x *analyticsRecorderServiceIngestNodeRoomStatesServer) SendAndClose(m *emptypb.Empty) error { - return x.ServerStream.SendMsg(m) -} - -func (x *analyticsRecorderServiceIngestNodeRoomStatesServer) Recv() (*livekit.AnalyticsNodeRooms, error) { - m := new(livekit.AnalyticsNodeRooms) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type AnalyticsRecorderService_IngestNodeRoomStatesServer = grpc.ClientStreamingServer[livekit.AnalyticsNodeRooms, emptypb.Empty] // AnalyticsRecorderService_ServiceDesc is the grpc.ServiceDesc for AnalyticsRecorderService service. // It's only intended for direct use with grpc.RegisterService, From 1567856e8f6d5c30b9e0a2748d9f96611c62fcbf Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 29 Jul 2024 16:45:12 -0700 Subject: [PATCH 3/6] Update comment --- livekit/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livekit/types.go b/livekit/types.go index ae37a0b62..9f4b1ba3b 100644 --- a/livekit/types.go +++ b/livekit/types.go @@ -107,7 +107,7 @@ func (r *RoomAgent) MarshalYAML() (interface{}, error) { } func marshalProto(o proto.Message) (map[string]interface{}, error) { - // Marshall the Node back to yaml to pass it to the protobuf specific unmarshaller + // Marshall the Node to yaml using the protobuf specific marshaller to ensure the proper field names are used str, err := protoyaml.MarshalOptions{UseProtoNames: true}.Marshal(o) if err != nil { return nil, err From 2e6300414b115a00710fc3392aa02e573e1c4a4a Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 29 Jul 2024 16:48:05 -0700 Subject: [PATCH 4/6] Create tame-peas-tickle.md --- .changeset/tame-peas-tickle.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tame-peas-tickle.md diff --git a/.changeset/tame-peas-tickle.md b/.changeset/tame-peas-tickle.md new file mode 100644 index 000000000..90fa88f17 --- /dev/null +++ b/.changeset/tame-peas-tickle.md @@ -0,0 +1,5 @@ +--- +"github.com/livekit/protocol": patch +--- + +Implement MarshalYAML on RoomConfiguration and related types From 984a72473ef05953f12119624e47e95d3cfeb02e Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 29 Jul 2024 16:59:42 -0700 Subject: [PATCH 5/6] Update grpc package --- go.mod | 19 +++++++++---------- go.sum | 36 ++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index c89b59115..187533731 100644 --- a/go.mod +++ b/go.mod @@ -35,8 +35,8 @@ require ( go.uber.org/zap/exp v0.2.0 golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 golang.org/x/mod v0.16.0 - google.golang.org/grpc v1.62.1 - google.golang.org/protobuf v1.33.0 + google.golang.org/grpc v1.65.0 + google.golang.org/protobuf v1.34.1 gopkg.in/yaml.v3 v3.0.1 ) @@ -45,11 +45,10 @@ require ( github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bufbuild/protovalidate-go v0.6.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/eapache/queue v1.1.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/cel-go v0.20.1 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -76,12 +75,12 @@ require ( github.com/prometheus/common v0.48.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sync v0.6.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.15.0 // indirect golang.org/x/tools v0.19.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect ) diff --git a/go.sum b/go.sum index 44667af65..a238d51c5 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/bufbuild/protovalidate-go v0.6.1 h1:uzW8r0CDvqApUChNj87VzZVoQSKhcVdw5 github.com/bufbuild/protovalidate-go v0.6.1/go.mod h1:4BR3rKEJiUiTy+sqsusFn2ladOf0kYmA2Reo6BHSBgQ= github.com/bufbuild/protoyaml-go v0.1.9 h1:anV5UtF1Mlvkkgp4NWA6U/zOnJFng8Orq4Vf3ZUQHBU= github.com/bufbuild/protoyaml-go v0.1.9/go.mod h1:KCBItkvZOK/zwGueLdH1Wx1RLyFn5rCH7YjQrdty2Wc= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -51,8 +51,6 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/cel-go v0.20.1 h1:nDx9r8S3L4pE61eDdt8igGj8rf5kjYR3ILxWIpWNi84= github.com/google/cel-go v0.20.1/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -220,8 +218,8 @@ golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIi golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -244,15 +242,15 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -298,8 +296,9 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -311,12 +310,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= -google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= +google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -325,8 +324,9 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= From 8f11bc2d9499dd32c7250e8da38abe0a23a92b42 Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Tue, 30 Jul 2024 11:49:14 -0700 Subject: [PATCH 6/6] WiP --- livekit/livekit_agent_dispatch_grpc.pb.go | 211 ---------------------- 1 file changed, 211 deletions(-) delete mode 100644 livekit/livekit_agent_dispatch_grpc.pb.go diff --git a/livekit/livekit_agent_dispatch_grpc.pb.go b/livekit/livekit_agent_dispatch_grpc.pb.go deleted file mode 100644 index ef00f55f0..000000000 --- a/livekit/livekit_agent_dispatch_grpc.pb.go +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2023 LiveKit, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v4.23.4 -// source: livekit_agent_dispatch.proto - -package livekit - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - AgentDispatchService_CreateDispatch_FullMethodName = "/livekit.AgentDispatchService/CreateDispatch" - AgentDispatchService_DeleteDispatch_FullMethodName = "/livekit.AgentDispatchService/DeleteDispatch" - AgentDispatchService_ListDispatch_FullMethodName = "/livekit.AgentDispatchService/ListDispatch" -) - -// AgentDispatchServiceClient is the client API for AgentDispatchService service. -// -// 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 AgentDispatchServiceClient interface { - CreateDispatch(ctx context.Context, in *CreateAgentDispatchRequest, opts ...grpc.CallOption) (*AgentDispatch, error) - DeleteDispatch(ctx context.Context, in *DeleteAgentDispatchRequest, opts ...grpc.CallOption) (*AgentDispatch, error) - ListDispatch(ctx context.Context, in *ListAgentDispatchRequesst, opts ...grpc.CallOption) (*ListAgentDispatchResponse, error) -} - -type agentDispatchServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewAgentDispatchServiceClient(cc grpc.ClientConnInterface) AgentDispatchServiceClient { - return &agentDispatchServiceClient{cc} -} - -func (c *agentDispatchServiceClient) CreateDispatch(ctx context.Context, in *CreateAgentDispatchRequest, opts ...grpc.CallOption) (*AgentDispatch, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(AgentDispatch) - err := c.cc.Invoke(ctx, AgentDispatchService_CreateDispatch_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *agentDispatchServiceClient) DeleteDispatch(ctx context.Context, in *DeleteAgentDispatchRequest, opts ...grpc.CallOption) (*AgentDispatch, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(AgentDispatch) - err := c.cc.Invoke(ctx, AgentDispatchService_DeleteDispatch_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *agentDispatchServiceClient) ListDispatch(ctx context.Context, in *ListAgentDispatchRequesst, opts ...grpc.CallOption) (*ListAgentDispatchResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListAgentDispatchResponse) - err := c.cc.Invoke(ctx, AgentDispatchService_ListDispatch_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AgentDispatchServiceServer is the server API for AgentDispatchService service. -// All implementations must embed UnimplementedAgentDispatchServiceServer -// for forward compatibility. -type AgentDispatchServiceServer interface { - CreateDispatch(context.Context, *CreateAgentDispatchRequest) (*AgentDispatch, error) - DeleteDispatch(context.Context, *DeleteAgentDispatchRequest) (*AgentDispatch, error) - ListDispatch(context.Context, *ListAgentDispatchRequesst) (*ListAgentDispatchResponse, error) - mustEmbedUnimplementedAgentDispatchServiceServer() -} - -// UnimplementedAgentDispatchServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedAgentDispatchServiceServer struct{} - -func (UnimplementedAgentDispatchServiceServer) CreateDispatch(context.Context, *CreateAgentDispatchRequest) (*AgentDispatch, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateDispatch not implemented") -} -func (UnimplementedAgentDispatchServiceServer) DeleteDispatch(context.Context, *DeleteAgentDispatchRequest) (*AgentDispatch, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteDispatch not implemented") -} -func (UnimplementedAgentDispatchServiceServer) ListDispatch(context.Context, *ListAgentDispatchRequesst) (*ListAgentDispatchResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListDispatch not implemented") -} -func (UnimplementedAgentDispatchServiceServer) mustEmbedUnimplementedAgentDispatchServiceServer() {} -func (UnimplementedAgentDispatchServiceServer) testEmbeddedByValue() {} - -// UnsafeAgentDispatchServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to AgentDispatchServiceServer will -// result in compilation errors. -type UnsafeAgentDispatchServiceServer interface { - mustEmbedUnimplementedAgentDispatchServiceServer() -} - -func RegisterAgentDispatchServiceServer(s grpc.ServiceRegistrar, srv AgentDispatchServiceServer) { - // If the following call pancis, it indicates UnimplementedAgentDispatchServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&AgentDispatchService_ServiceDesc, srv) -} - -func _AgentDispatchService_CreateDispatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateAgentDispatchRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AgentDispatchServiceServer).CreateDispatch(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AgentDispatchService_CreateDispatch_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AgentDispatchServiceServer).CreateDispatch(ctx, req.(*CreateAgentDispatchRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AgentDispatchService_DeleteDispatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteAgentDispatchRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AgentDispatchServiceServer).DeleteDispatch(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AgentDispatchService_DeleteDispatch_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AgentDispatchServiceServer).DeleteDispatch(ctx, req.(*DeleteAgentDispatchRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AgentDispatchService_ListDispatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListAgentDispatchRequesst) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AgentDispatchServiceServer).ListDispatch(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AgentDispatchService_ListDispatch_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AgentDispatchServiceServer).ListDispatch(ctx, req.(*ListAgentDispatchRequesst)) - } - return interceptor(ctx, in, info, handler) -} - -// AgentDispatchService_ServiceDesc is the grpc.ServiceDesc for AgentDispatchService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var AgentDispatchService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "livekit.AgentDispatchService", - HandlerType: (*AgentDispatchServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateDispatch", - Handler: _AgentDispatchService_CreateDispatch_Handler, - }, - { - MethodName: "DeleteDispatch", - Handler: _AgentDispatchService_DeleteDispatch_Handler, - }, - { - MethodName: "ListDispatch", - Handler: _AgentDispatchService_ListDispatch_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "livekit_agent_dispatch.proto", -}