github.com/livekit/protocol@v1.39.3/rpc/agent.psrpc.go (about) 1 // Code generated by protoc-gen-psrpc v0.6.0, DO NOT EDIT. 2 // source: rpc/agent.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 google_protobuf "google.golang.org/protobuf/types/known/emptypb" 17 import livekit2 "github.com/livekit/protocol/livekit" 18 19 var _ = version.PsrpcVersion_0_6 20 21 // ============================== 22 // AgentInternal Client Interface 23 // ============================== 24 25 type AgentInternalClient interface { 26 CheckEnabled(ctx context.Context, req *CheckEnabledRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*CheckEnabledResponse], error) 27 28 JobRequest(ctx context.Context, namespace string, jobType string, req *livekit2.Job, opts ...psrpc.RequestOption) (*JobRequestResponse, error) 29 30 JobTerminate(ctx context.Context, jobId string, req *JobTerminateRequest, opts ...psrpc.RequestOption) (*JobTerminateResponse, error) 31 32 SubscribeWorkerRegistered(ctx context.Context, handlerNamespace string) (psrpc.Subscription[*google_protobuf.Empty], error) 33 34 // Close immediately, without waiting for pending RPCs 35 Close() 36 } 37 38 // ================================== 39 // AgentInternal ServerImpl Interface 40 // ================================== 41 42 type AgentInternalServerImpl interface { 43 CheckEnabled(context.Context, *CheckEnabledRequest) (*CheckEnabledResponse, error) 44 45 JobRequest(context.Context, *livekit2.Job) (*JobRequestResponse, error) 46 JobRequestAffinity(context.Context, *livekit2.Job) float32 47 48 JobTerminate(context.Context, *JobTerminateRequest) (*JobTerminateResponse, error) 49 } 50 51 // ============================== 52 // AgentInternal Server Interface 53 // ============================== 54 55 type AgentInternalServer interface { 56 RegisterJobRequestTopic(namespace string, jobType string) error 57 DeregisterJobRequestTopic(namespace string, jobType string) 58 RegisterJobTerminateTopic(jobId string) error 59 DeregisterJobTerminateTopic(jobId string) 60 PublishWorkerRegistered(ctx context.Context, handlerNamespace string, msg *google_protobuf.Empty) error 61 62 // Close and wait for pending RPCs to complete 63 Shutdown() 64 65 // Close immediately, without waiting for pending RPCs 66 Kill() 67 } 68 69 // ==================== 70 // AgentInternal Client 71 // ==================== 72 73 type agentInternalClient struct { 74 client *client.RPCClient 75 } 76 77 // NewAgentInternalClient creates a psrpc client that implements the AgentInternalClient interface. 78 func NewAgentInternalClient(bus psrpc.MessageBus, opts ...psrpc.ClientOption) (AgentInternalClient, error) { 79 sd := &info.ServiceDefinition{ 80 Name: "AgentInternal", 81 ID: rand.NewClientID(), 82 } 83 84 sd.RegisterMethod("CheckEnabled", false, true, false, false) 85 sd.RegisterMethod("JobRequest", true, false, true, false) 86 sd.RegisterMethod("JobTerminate", false, false, true, true) 87 sd.RegisterMethod("WorkerRegistered", false, true, false, false) 88 89 rpcClient, err := client.NewRPCClient(sd, bus, opts...) 90 if err != nil { 91 return nil, err 92 } 93 94 return &agentInternalClient{ 95 client: rpcClient, 96 }, nil 97 } 98 99 func (c *agentInternalClient) CheckEnabled(ctx context.Context, req *CheckEnabledRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*CheckEnabledResponse], error) { 100 return client.RequestMulti[*CheckEnabledResponse](ctx, c.client, "CheckEnabled", nil, req, opts...) 101 } 102 103 func (c *agentInternalClient) JobRequest(ctx context.Context, namespace string, jobType string, req *livekit2.Job, opts ...psrpc.RequestOption) (*JobRequestResponse, error) { 104 return client.RequestSingle[*JobRequestResponse](ctx, c.client, "JobRequest", []string{namespace, jobType}, req, opts...) 105 } 106 107 func (c *agentInternalClient) JobTerminate(ctx context.Context, jobId string, req *JobTerminateRequest, opts ...psrpc.RequestOption) (*JobTerminateResponse, error) { 108 return client.RequestSingle[*JobTerminateResponse](ctx, c.client, "JobTerminate", []string{jobId}, req, opts...) 109 } 110 111 func (c *agentInternalClient) SubscribeWorkerRegistered(ctx context.Context, handlerNamespace string) (psrpc.Subscription[*google_protobuf.Empty], error) { 112 return client.Join[*google_protobuf.Empty](ctx, c.client, "WorkerRegistered", []string{handlerNamespace}) 113 } 114 115 func (s *agentInternalClient) Close() { 116 s.client.Close() 117 } 118 119 // ==================== 120 // AgentInternal Server 121 // ==================== 122 123 type agentInternalServer struct { 124 svc AgentInternalServerImpl 125 rpc *server.RPCServer 126 } 127 128 // NewAgentInternalServer builds a RPCServer that will route requests 129 // to the corresponding method in the provided svc implementation. 130 func NewAgentInternalServer(svc AgentInternalServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (AgentInternalServer, error) { 131 sd := &info.ServiceDefinition{ 132 Name: "AgentInternal", 133 ID: rand.NewServerID(), 134 } 135 136 s := server.NewRPCServer(sd, bus, opts...) 137 138 sd.RegisterMethod("CheckEnabled", false, true, false, false) 139 var err error 140 err = server.RegisterHandler(s, "CheckEnabled", nil, svc.CheckEnabled, nil) 141 if err != nil { 142 s.Close(false) 143 return nil, err 144 } 145 146 sd.RegisterMethod("JobRequest", true, false, true, false) 147 sd.RegisterMethod("JobTerminate", false, false, true, true) 148 sd.RegisterMethod("WorkerRegistered", false, true, false, false) 149 return &agentInternalServer{ 150 svc: svc, 151 rpc: s, 152 }, nil 153 } 154 155 func (s *agentInternalServer) RegisterJobRequestTopic(namespace string, jobType string) error { 156 return server.RegisterHandler(s.rpc, "JobRequest", []string{namespace, jobType}, s.svc.JobRequest, s.svc.JobRequestAffinity) 157 } 158 159 func (s *agentInternalServer) DeregisterJobRequestTopic(namespace string, jobType string) { 160 s.rpc.DeregisterHandler("JobRequest", []string{namespace, jobType}) 161 } 162 163 func (s *agentInternalServer) RegisterJobTerminateTopic(jobId string) error { 164 return server.RegisterHandler(s.rpc, "JobTerminate", []string{jobId}, s.svc.JobTerminate, nil) 165 } 166 167 func (s *agentInternalServer) DeregisterJobTerminateTopic(jobId string) { 168 s.rpc.DeregisterHandler("JobTerminate", []string{jobId}) 169 } 170 171 func (s *agentInternalServer) PublishWorkerRegistered(ctx context.Context, handlerNamespace string, msg *google_protobuf.Empty) error { 172 return s.rpc.Publish(ctx, "WorkerRegistered", []string{handlerNamespace}, msg) 173 } 174 175 func (s *agentInternalServer) Shutdown() { 176 s.rpc.Close(false) 177 } 178 179 func (s *agentInternalServer) Kill() { 180 s.rpc.Close(true) 181 } 182 183 var psrpcFileDescriptor0 = []byte{ 184 // 566 bytes of a gzipped FileDescriptorProto 185 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xdf, 0x8e, 0xd2, 0x4e, 186 0x18, 0xfd, 0x0d, 0x2c, 0x04, 0x06, 0xf6, 0xb7, 0x65, 0xba, 0x28, 0x5b, 0x63, 0x76, 0xe9, 0x8d, 187 0x44, 0x93, 0xd6, 0xe0, 0xb5, 0x71, 0x59, 0xb7, 0x1a, 0x88, 0x40, 0xec, 0x76, 0x35, 0x31, 0x31, 188 0x4d, 0x5b, 0x3e, 0xa1, 0x4b, 0xe9, 0x8c, 0xd3, 0xc1, 0x64, 0x1f, 0x81, 0xd7, 0xe1, 0x79, 0x7c, 189 0x0c, 0x1f, 0xc0, 0xf4, 0x0f, 0xb5, 0x6c, 0xf0, 0xc2, 0xcb, 0x9e, 0x73, 0xfa, 0xe5, 0x3b, 0xe7, 190 0xcc, 0x87, 0x4f, 0x38, 0xf3, 0x74, 0x67, 0x0e, 0xa1, 0xd0, 0x18, 0xa7, 0x82, 0x92, 0x32, 0x67, 191 0x9e, 0xf2, 0x64, 0x4e, 0xe9, 0x3c, 0x00, 0x3d, 0x81, 0xdc, 0xf5, 0x37, 0x1d, 0x56, 0x4c, 0xdc, 192 0xa7, 0x0a, 0xe5, 0x98, 0x32, 0xe1, 0xd3, 0x30, 0xca, 0x3e, 0xe5, 0xc0, 0xff, 0x01, 0x4b, 0x5f, 193 0xd8, 0x85, 0x29, 0x6a, 0x1b, 0xcb, 0x6f, 0x17, 0xe0, 0x2d, 0x8d, 0xd0, 0x71, 0x03, 0x98, 0x99, 194 0xf0, 0x7d, 0x0d, 0x91, 0x50, 0x7f, 0x22, 0x7c, 0xba, 0x8f, 0x47, 0x8c, 0x86, 0x11, 0x90, 0x2e, 195 0x6e, 0x72, 0x4a, 0x57, 0x36, 0xa4, 0x78, 0x07, 0x5d, 0xa0, 0x5e, 0xcd, 0x6c, 0xc4, 0x58, 0x26, 196 0x25, 0x2f, 0x70, 0x8b, 0xad, 0xdd, 0xc0, 0x8f, 0x16, 0xc0, 0x73, 0x5d, 0x29, 0xd1, 0x49, 0x39, 197 0xb1, 0x13, 0xeb, 0x58, 0x66, 0x0e, 0x17, 0xbe, 0xe7, 0x33, 0x27, 0x14, 0xb9, 0xbc, 0x92, 0xc8, 198 0x49, 0x81, 0xda, 0xfd, 0xa0, 0x62, 0x1c, 0x3a, 0x2b, 0x88, 0x98, 0xe3, 0x41, 0xd4, 0x29, 0x5f, 199 0x94, 0x7b, 0xf5, 0xab, 0x52, 0x07, 0x99, 0x05, 0x94, 0x9c, 0xe3, 0x46, 0xe2, 0xd1, 0x4e, 0xb0, 200 0xce, 0x51, 0x2c, 0x32, 0x71, 0x02, 0x4d, 0x62, 0x44, 0x7d, 0x8d, 0xc9, 0x88, 0xba, 0x99, 0xd9, 201 0xdc, 0xdb, 0x33, 0x5c, 0x89, 0x84, 0x23, 0x20, 0x31, 0xd5, 0xe8, 0xb7, 0xb4, 0x2c, 0x30, 0x6d, 202 0x44, 0xdd, 0x9b, 0x98, 0x30, 0x53, 0x5e, 0xfd, 0x8a, 0xe5, 0x11, 0x75, 0x2d, 0xe0, 0x2b, 0x3f, 203 0x8c, 0xe1, 0x74, 0x0e, 0x69, 0xe3, 0xea, 0x1d, 0x75, 0x6d, 0x3f, 0x4d, 0xa5, 0x6e, 0x56, 0xee, 204 0xa8, 0x3b, 0x8c, 0x2d, 0x56, 0x39, 0x38, 0x11, 0x0d, 0x93, 0x10, 0xfe, 0xef, 0x3f, 0xd6, 0x38, 205 0xf3, 0xb4, 0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