github.com/livekit/protocol@v1.39.3/rpc/roommanager.psrpc.go (about) 1 // Code generated by protoc-gen-psrpc v0.6.0, DO NOT EDIT. 2 // source: rpc/roommanager.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 livekit1 "github.com/livekit/protocol/livekit" 17 import livekit6 "github.com/livekit/protocol/livekit" 18 19 var _ = version.PsrpcVersion_0_6 20 21 // ============================ 22 // RoomManager Client Interface 23 // ============================ 24 25 type RoomManagerClient[NodeIdTopicType ~string] interface { 26 CreateRoom(ctx context.Context, nodeId NodeIdTopicType, req *livekit6.CreateRoomRequest, opts ...psrpc.RequestOption) (*livekit1.Room, error) 27 28 // Close immediately, without waiting for pending RPCs 29 Close() 30 } 31 32 // ================================ 33 // RoomManager ServerImpl Interface 34 // ================================ 35 36 type RoomManagerServerImpl interface { 37 CreateRoom(context.Context, *livekit6.CreateRoomRequest) (*livekit1.Room, error) 38 } 39 40 // ============================ 41 // RoomManager Server Interface 42 // ============================ 43 44 type RoomManagerServer[NodeIdTopicType ~string] interface { 45 RegisterCreateRoomTopic(nodeId NodeIdTopicType) error 46 DeregisterCreateRoomTopic(nodeId NodeIdTopicType) 47 RegisterAllNodeTopics(nodeId NodeIdTopicType) error 48 DeregisterAllNodeTopics(nodeId NodeIdTopicType) 49 50 // Close and wait for pending RPCs to complete 51 Shutdown() 52 53 // Close immediately, without waiting for pending RPCs 54 Kill() 55 } 56 57 // ================== 58 // RoomManager Client 59 // ================== 60 61 type roomManagerClient[NodeIdTopicType ~string] struct { 62 client *client.RPCClient 63 } 64 65 // NewRoomManagerClient creates a psrpc client that implements the RoomManagerClient interface. 66 func NewRoomManagerClient[NodeIdTopicType ~string](bus psrpc.MessageBus, opts ...psrpc.ClientOption) (RoomManagerClient[NodeIdTopicType], error) { 67 sd := &info.ServiceDefinition{ 68 Name: "RoomManager", 69 ID: rand.NewClientID(), 70 } 71 72 sd.RegisterMethod("CreateRoom", false, false, true, true) 73 74 rpcClient, err := client.NewRPCClient(sd, bus, opts...) 75 if err != nil { 76 return nil, err 77 } 78 79 return &roomManagerClient[NodeIdTopicType]{ 80 client: rpcClient, 81 }, nil 82 } 83 84 func (c *roomManagerClient[NodeIdTopicType]) CreateRoom(ctx context.Context, nodeId NodeIdTopicType, req *livekit6.CreateRoomRequest, opts ...psrpc.RequestOption) (*livekit1.Room, error) { 85 return client.RequestSingle[*livekit1.Room](ctx, c.client, "CreateRoom", []string{string(nodeId)}, req, opts...) 86 } 87 88 func (s *roomManagerClient[NodeIdTopicType]) Close() { 89 s.client.Close() 90 } 91 92 // ================== 93 // RoomManager Server 94 // ================== 95 96 type roomManagerServer[NodeIdTopicType ~string] struct { 97 svc RoomManagerServerImpl 98 rpc *server.RPCServer 99 } 100 101 // NewRoomManagerServer builds a RPCServer that will route requests 102 // to the corresponding method in the provided svc implementation. 103 func NewRoomManagerServer[NodeIdTopicType ~string](svc RoomManagerServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (RoomManagerServer[NodeIdTopicType], error) { 104 sd := &info.ServiceDefinition{ 105 Name: "RoomManager", 106 ID: rand.NewServerID(), 107 } 108 109 s := server.NewRPCServer(sd, bus, opts...) 110 111 sd.RegisterMethod("CreateRoom", false, false, true, true) 112 return &roomManagerServer[NodeIdTopicType]{ 113 svc: svc, 114 rpc: s, 115 }, nil 116 } 117 118 func (s *roomManagerServer[NodeIdTopicType]) RegisterCreateRoomTopic(nodeId NodeIdTopicType) error { 119 return server.RegisterHandler(s.rpc, "CreateRoom", []string{string(nodeId)}, s.svc.CreateRoom, nil) 120 } 121 122 func (s *roomManagerServer[NodeIdTopicType]) DeregisterCreateRoomTopic(nodeId NodeIdTopicType) { 123 s.rpc.DeregisterHandler("CreateRoom", []string{string(nodeId)}) 124 } 125 126 func (s *roomManagerServer[NodeIdTopicType]) allNodeTopicRegisterers() server.RegistererSlice { 127 return server.RegistererSlice{ 128 server.NewRegisterer(s.RegisterCreateRoomTopic, s.DeregisterCreateRoomTopic), 129 } 130 } 131 132 func (s *roomManagerServer[NodeIdTopicType]) RegisterAllNodeTopics(nodeId NodeIdTopicType) error { 133 return s.allNodeTopicRegisterers().Register(nodeId) 134 } 135 136 func (s *roomManagerServer[NodeIdTopicType]) DeregisterAllNodeTopics(nodeId NodeIdTopicType) { 137 s.allNodeTopicRegisterers().Deregister(nodeId) 138 } 139 140 func (s *roomManagerServer[NodeIdTopicType]) Shutdown() { 141 s.rpc.Close(false) 142 } 143 144 func (s *roomManagerServer[NodeIdTopicType]) Kill() { 145 s.rpc.Close(true) 146 } 147 148 var psrpcFileDescriptor8 = []byte{ 149 // 185 bytes of a gzipped FileDescriptorProto 150 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0xcd, 0x4d, 0x0a, 0xc2, 0x30, 151 0x10, 0x05, 0x60, 0x8a, 0xa2, 0x10, 0x29, 0x68, 0xb0, 0xa0, 0xd9, 0x88, 0x1e, 0x20, 0x01, 0xbd, 152 0x81, 0xae, 0xdd, 0x74, 0xe9, 0xa6, 0xa4, 0xe9, 0x50, 0x83, 0x4d, 0x27, 0xa6, 0xa9, 0x77, 0xf0, 153 0x3a, 0x9e, 0x50, 0xd2, 0x1f, 0xdd, 0x0c, 0xcc, 0x37, 0xbc, 0x37, 0x24, 0x71, 0x56, 0x09, 0x87, 154 0x68, 0x8c, 0xac, 0x65, 0x09, 0x8e, 0x5b, 0x87, 0x1e, 0xe9, 0xc4, 0x59, 0xc5, 0x62, 0xb4, 0x5e, 155 0x63, 0xdd, 0xf4, 0xc6, 0xd6, 0x95, 0x7e, 0xc1, 0x43, 0xfb, 0xcc, 0x60, 0x01, 0xd5, 0xa8, 0x74, 156 0xd4, 0x50, 0xd2, 0xdb, 0x51, 0x92, 0x45, 0x8a, 0x68, 0xae, 0x7d, 0x25, 0x4d, 0x09, 0xb9, 0x38, 157 0x90, 0x1e, 0x02, 0x52, 0xc6, 0x87, 0x04, 0xff, 0x63, 0x0a, 0xcf, 0x16, 0x1a, 0xcf, 0xe2, 0xdf, 158 0x2d, 0xe8, 0x61, 0xfb, 0x79, 0x47, 0xc9, 0x32, 0x62, 0x2b, 0x32, 0xad, 0xb1, 0x00, 0x3a, 0x0f, 159 0x33, 0xd3, 0xc5, 0x26, 0x3a, 0xef, 0x6f, 0xbb, 0x52, 0xfb, 0x7b, 0x9b, 0x73, 0x85, 0x46, 0x0c, 160 0x29, 0xd1, 0xbd, 0x57, 0x58, 0x09, 0x67, 0x55, 0x3e, 0xeb, 0xb6, 0xd3, 0x37, 0x00, 0x00, 0xff, 161 0xff, 0x3b, 0xa9, 0xd5, 0x75, 0xe3, 0x00, 0x00, 0x00, 162 }