github.com/livekit/protocol@v1.39.3/rpc/agent_dispatch.psrpc.go (about) 1 // Code generated by protoc-gen-psrpc v0.6.0, DO NOT EDIT. 2 // source: rpc/agent_dispatch.proto 3 4 package rpc 5 6 import ( 7 "context" 8 9 "github.com/livekit/psrpc" 10 "github.com/livekit/psrpc/pkg/client" 11 "github.com/livekit/psrpc/pkg/info" 12 "github.com/livekit/psrpc/pkg/rand" 13 "github.com/livekit/psrpc/pkg/server" 14 "github.com/livekit/psrpc/version" 15 ) 16 import livekit3 "github.com/livekit/protocol/livekit" 17 18 var _ = version.PsrpcVersion_0_6 19 20 // ====================================== 21 // AgentDispatchInternal Client Interface 22 // ====================================== 23 24 type AgentDispatchInternalClient[RoomTopicType ~string] interface { 25 CreateDispatch(ctx context.Context, room RoomTopicType, req *livekit3.AgentDispatch, opts ...psrpc.RequestOption) (*livekit3.AgentDispatch, error) 26 27 DeleteDispatch(ctx context.Context, room RoomTopicType, req *livekit3.DeleteAgentDispatchRequest, opts ...psrpc.RequestOption) (*livekit3.AgentDispatch, error) 28 29 ListDispatch(ctx context.Context, room RoomTopicType, req *livekit3.ListAgentDispatchRequest, opts ...psrpc.RequestOption) (*livekit3.ListAgentDispatchResponse, error) 30 31 // Close immediately, without waiting for pending RPCs 32 Close() 33 } 34 35 // ========================================== 36 // AgentDispatchInternal ServerImpl Interface 37 // ========================================== 38 39 type AgentDispatchInternalServerImpl interface { 40 CreateDispatch(context.Context, *livekit3.AgentDispatch) (*livekit3.AgentDispatch, error) 41 42 DeleteDispatch(context.Context, *livekit3.DeleteAgentDispatchRequest) (*livekit3.AgentDispatch, error) 43 44 ListDispatch(context.Context, *livekit3.ListAgentDispatchRequest) (*livekit3.ListAgentDispatchResponse, error) 45 } 46 47 // ====================================== 48 // AgentDispatchInternal Server Interface 49 // ====================================== 50 51 type AgentDispatchInternalServer[RoomTopicType ~string] interface { 52 RegisterCreateDispatchTopic(room RoomTopicType) error 53 DeregisterCreateDispatchTopic(room RoomTopicType) 54 RegisterDeleteDispatchTopic(room RoomTopicType) error 55 DeregisterDeleteDispatchTopic(room RoomTopicType) 56 RegisterListDispatchTopic(room RoomTopicType) error 57 DeregisterListDispatchTopic(room RoomTopicType) 58 RegisterAllRoomTopics(room RoomTopicType) error 59 DeregisterAllRoomTopics(room RoomTopicType) 60 61 // Close and wait for pending RPCs to complete 62 Shutdown() 63 64 // Close immediately, without waiting for pending RPCs 65 Kill() 66 } 67 68 // ============================ 69 // AgentDispatchInternal Client 70 // ============================ 71 72 type agentDispatchInternalClient[RoomTopicType ~string] struct { 73 client *client.RPCClient 74 } 75 76 // NewAgentDispatchInternalClient creates a psrpc client that implements the AgentDispatchInternalClient interface. 77 func NewAgentDispatchInternalClient[RoomTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (AgentDispatchInternalClient[RoomTopicType], error) { 78 sd := &info.ServiceDefinition{ 79 Name: "AgentDispatchInternal", 80 ID: rand.NewClientID(), 81 } 82 83 sd.RegisterMethod("CreateDispatch", false, false, true, true) 84 sd.RegisterMethod("DeleteDispatch", false, false, true, true) 85 sd.RegisterMethod("ListDispatch", false, false, true, true) 86 87 rpcClient, err := client.NewRPCClient(sd, bus, opts...) 88 if err != nil { 89 return nil, err 90 } 91 92 return &agentDispatchInternalClient[RoomTopicType]{ 93 client: rpcClient, 94 }, nil 95 } 96 97 func (c *agentDispatchInternalClient[RoomTopicType]) CreateDispatch(ctx context.Context, room RoomTopicType, req *livekit3.AgentDispatch, opts ...psrpc.RequestOption) (*livekit3.AgentDispatch, error) { 98 return client.RequestSingle[*livekit3.AgentDispatch](ctx, c.client, "CreateDispatch", []string{string(room)}, req, opts...) 99 } 100 101 func (c *agentDispatchInternalClient[RoomTopicType]) DeleteDispatch(ctx context.Context, room RoomTopicType, req *livekit3.DeleteAgentDispatchRequest, opts ...psrpc.RequestOption) (*livekit3.AgentDispatch, error) { 102 return client.RequestSingle[*livekit3.AgentDispatch](ctx, c.client, "DeleteDispatch", []string{string(room)}, req, opts...) 103 } 104 105 func (c *agentDispatchInternalClient[RoomTopicType]) ListDispatch(ctx context.Context, room RoomTopicType, req *livekit3.ListAgentDispatchRequest, opts ...psrpc.RequestOption) (*livekit3.ListAgentDispatchResponse, error) { 106 return client.RequestSingle[*livekit3.ListAgentDispatchResponse](ctx, c.client, "ListDispatch", []string{string(room)}, req, opts...) 107 } 108 109 func (s *agentDispatchInternalClient[RoomTopicType]) Close() { 110 s.client.Close() 111 } 112 113 // ============================ 114 // AgentDispatchInternal Server 115 // ============================ 116 117 type agentDispatchInternalServer[RoomTopicType ~string] struct { 118 svc AgentDispatchInternalServerImpl 119 rpc *server.RPCServer 120 } 121 122 // NewAgentDispatchInternalServer builds a RPCServer that will route requests 123 // to the corresponding method in the provided svc implementation. 124 func NewAgentDispatchInternalServer[RoomTopicType ~string](svc AgentDispatchInternalServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (AgentDispatchInternalServer[RoomTopicType], error) { 125 sd := &info.ServiceDefinition{ 126 Name: "AgentDispatchInternal", 127 ID: rand.NewServerID(), 128 } 129 130 s := server.NewRPCServer(sd, bus, opts...) 131 132 sd.RegisterMethod("CreateDispatch", false, false, true, true) 133 sd.RegisterMethod("DeleteDispatch", false, false, true, true) 134 sd.RegisterMethod("ListDispatch", false, false, true, true) 135 return &agentDispatchInternalServer[RoomTopicType]{ 136 svc: svc, 137 rpc: s, 138 }, nil 139 } 140 141 func (s *agentDispatchInternalServer[RoomTopicType]) RegisterCreateDispatchTopic(room RoomTopicType) error { 142 return server.RegisterHandler(s.rpc, "CreateDispatch", []string{string(room)}, s.svc.CreateDispatch, nil) 143 } 144 145 func (s *agentDispatchInternalServer[RoomTopicType]) DeregisterCreateDispatchTopic(room RoomTopicType) { 146 s.rpc.DeregisterHandler("CreateDispatch", []string{string(room)}) 147 } 148 149 func (s *agentDispatchInternalServer[RoomTopicType]) RegisterDeleteDispatchTopic(room RoomTopicType) error { 150 return server.RegisterHandler(s.rpc, "DeleteDispatch", []string{string(room)}, s.svc.DeleteDispatch, nil) 151 } 152 153 func (s *agentDispatchInternalServer[RoomTopicType]) DeregisterDeleteDispatchTopic(room RoomTopicType) { 154 s.rpc.DeregisterHandler("DeleteDispatch", []string{string(room)}) 155 } 156 157 func (s *agentDispatchInternalServer[RoomTopicType]) RegisterListDispatchTopic(room RoomTopicType) error { 158 return server.RegisterHandler(s.rpc, "ListDispatch", []string{string(room)}, s.svc.ListDispatch, nil) 159 } 160 161 func (s *agentDispatchInternalServer[RoomTopicType]) DeregisterListDispatchTopic(room RoomTopicType) { 162 s.rpc.DeregisterHandler("ListDispatch", []string{string(room)}) 163 } 164 165 func (s *agentDispatchInternalServer[RoomTopicType]) allRoomTopicRegisterers() server.RegistererSlice { 166 return server.RegistererSlice{ 167 server.NewRegisterer(s.RegisterCreateDispatchTopic, s.DeregisterCreateDispatchTopic), 168 server.NewRegisterer(s.RegisterDeleteDispatchTopic, s.DeregisterDeleteDispatchTopic), 169 server.NewRegisterer(s.RegisterListDispatchTopic, s.DeregisterListDispatchTopic), 170 } 171 } 172 173 func (s *agentDispatchInternalServer[RoomTopicType]) RegisterAllRoomTopics(room RoomTopicType) error { 174 return s.allRoomTopicRegisterers().Register(room) 175 } 176 177 func (s *agentDispatchInternalServer[RoomTopicType]) DeregisterAllRoomTopics(room RoomTopicType) { 178 s.allRoomTopicRegisterers().Deregister(room) 179 } 180 181 func (s *agentDispatchInternalServer[RoomTopicType]) Shutdown() { 182 s.rpc.Close(false) 183 } 184 185 func (s *agentDispatchInternalServer[RoomTopicType]) Kill() { 186 s.rpc.Close(true) 187 } 188 189 var psrpcFileDescriptor1 = []byte{ 190 // 228 bytes of a gzipped FileDescriptorProto 191 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x2a, 0x48, 0xd6, 192 0x4f, 0x4c, 0x4f, 0xcd, 0x2b, 0x89, 0x4f, 0xc9, 0x2c, 0x2e, 0x48, 0x2c, 0x49, 0xce, 0xd0, 0x2b, 193 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2e, 0x2a, 0x48, 0x96, 0xe2, 0xcd, 0x2f, 0x28, 0xc9, 0xcc, 194 0xcf, 0x2b, 0x86, 0x88, 0x49, 0xc9, 0xe4, 0x64, 0x96, 0xa5, 0x66, 0x67, 0x96, 0xc4, 0x63, 0xd3, 195 0x61, 0x74, 0x9c, 0x89, 0x4b, 0xd4, 0x11, 0x24, 0xe1, 0x02, 0x15, 0xf7, 0xcc, 0x2b, 0x49, 0x2d, 196 0xca, 0x4b, 0xcc, 0x11, 0x8a, 0xe0, 0xe2, 0x73, 0x2e, 0x4a, 0x4d, 0x2c, 0x49, 0x85, 0xc9, 0x08, 197 0x89, 0xe9, 0x41, 0x8d, 0xd2, 0x43, 0xd1, 0x21, 0x85, 0x43, 0x5c, 0x49, 0x6c, 0x53, 0x27, 0xa3, 198 0x90, 0x00, 0xa3, 0x14, 0x1f, 0x17, 0x4b, 0x51, 0x7e, 0x7e, 0xae, 0x10, 0x98, 0x94, 0x60, 0x14, 199 0x4a, 0xe5, 0xe2, 0x73, 0x49, 0xcd, 0x49, 0x45, 0x32, 0x59, 0x19, 0x6e, 0x02, 0x44, 0x02, 0xc5, 200 0x9c, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2, 0x12, 0x92, 0xad, 0xc9, 0xe5, 0xe2, 0xf1, 0xc9, 0x2c, 201 0x86, 0xab, 0x13, 0x52, 0x84, 0xeb, 0x07, 0x09, 0x63, 0xb5, 0x42, 0x09, 0x9f, 0x92, 0xe2, 0x82, 202 0xfc, 0xbc, 0xe2, 0x54, 0x5c, 0xd6, 0x39, 0x29, 0x46, 0xc9, 0xa7, 0x67, 0x96, 0x64, 0x94, 0x26, 203 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xcd, 0xd1, 0x07, 0x87, 0x72, 0x72, 0x7e, 0x8e, 0x7e, 0x51, 204 0x41, 0x72, 0x12, 0x1b, 0x98, 0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd1, 0xc4, 0x73, 0xc1, 205 0xc1, 0x01, 0x00, 0x00, 206 }