github.com/whoyao/protocol@v0.0.0-20230519045905-2d8ace718ca5/rpc/egress.psrpc.go (about)

     1  // Code generated by protoc-gen-psrpc v0.3.0, DO NOT EDIT.
     2  // source: rpc/egress.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/server"
    13  	"github.com/livekit/psrpc/version"
    14  )
    15  import livekit1 "github.com/whoyao/protocol/livekit"
    16  
    17  var _ = version.PsrpcVersion_0_3_0
    18  
    19  // ===============================
    20  // EgressInternal Client Interface
    21  // ===============================
    22  
    23  type EgressInternalClient interface {
    24  	StartEgress(ctx context.Context, topic string, req *StartEgressRequest, opts ...psrpc.RequestOption) (*livekit1.EgressInfo, error)
    25  
    26  	ListActiveEgress(ctx context.Context, req *ListActiveEgressRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*ListActiveEgressResponse], error)
    27  }
    28  
    29  // ===================================
    30  // EgressInternal ServerImpl Interface
    31  // ===================================
    32  
    33  type EgressInternalServerImpl interface {
    34  	StartEgress(context.Context, *StartEgressRequest) (*livekit1.EgressInfo, error)
    35  	StartEgressAffinity(*StartEgressRequest) float32
    36  
    37  	ListActiveEgress(context.Context, *ListActiveEgressRequest) (*ListActiveEgressResponse, error)
    38  }
    39  
    40  // ===============================
    41  // EgressInternal Server Interface
    42  // ===============================
    43  
    44  type EgressInternalServer interface {
    45  	RegisterStartEgressTopic(topic string) error
    46  	DeregisterStartEgressTopic(topic string)
    47  
    48  	// Close and wait for pending RPCs to complete
    49  	Shutdown()
    50  
    51  	// Close immediately, without waiting for pending RPCs
    52  	Kill()
    53  }
    54  
    55  // =====================
    56  // EgressInternal Client
    57  // =====================
    58  
    59  type egressInternalClient struct {
    60  	client *client.RPCClient
    61  }
    62  
    63  // NewEgressInternalClient creates a psrpc client that implements the EgressInternalClient interface.
    64  func NewEgressInternalClient(clientID string, bus psrpc.MessageBus, opts ...psrpc.ClientOption) (EgressInternalClient, error) {
    65  	sd := &info.ServiceDefinition{
    66  		Name: "EgressInternal",
    67  		ID:   clientID,
    68  	}
    69  
    70  	sd.RegisterMethod("StartEgress", true, false, true)
    71  	sd.RegisterMethod("ListActiveEgress", false, true, false)
    72  
    73  	rpcClient, err := client.NewRPCClient(sd, bus, opts...)
    74  	if err != nil {
    75  		return nil, err
    76  	}
    77  
    78  	return &egressInternalClient{
    79  		client: rpcClient,
    80  	}, nil
    81  }
    82  
    83  func (c *egressInternalClient) StartEgress(ctx context.Context, topic string, req *StartEgressRequest, opts ...psrpc.RequestOption) (*livekit1.EgressInfo, error) {
    84  	return client.RequestSingle[*livekit1.EgressInfo](ctx, c.client, "StartEgress", []string{topic}, req, opts...)
    85  }
    86  
    87  func (c *egressInternalClient) ListActiveEgress(ctx context.Context, req *ListActiveEgressRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*ListActiveEgressResponse], error) {
    88  	return client.RequestMulti[*ListActiveEgressResponse](ctx, c.client, "ListActiveEgress", nil, req, opts...)
    89  }
    90  
    91  // =====================
    92  // EgressInternal Server
    93  // =====================
    94  
    95  type egressInternalServer struct {
    96  	svc EgressInternalServerImpl
    97  	rpc *server.RPCServer
    98  }
    99  
   100  // NewEgressInternalServer builds a RPCServer that will route requests
   101  // to the corresponding method in the provided svc implementation.
   102  func NewEgressInternalServer(serverID string, svc EgressInternalServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (EgressInternalServer, error) {
   103  	sd := &info.ServiceDefinition{
   104  		Name: "EgressInternal",
   105  		ID:   serverID,
   106  	}
   107  
   108  	s := server.NewRPCServer(sd, bus, opts...)
   109  
   110  	sd.RegisterMethod("StartEgress", true, false, true)
   111  	sd.RegisterMethod("ListActiveEgress", false, true, false)
   112  	var err error
   113  	err = server.RegisterHandler(s, "ListActiveEgress", nil, svc.ListActiveEgress, nil)
   114  	if err != nil {
   115  		s.Close(false)
   116  		return nil, err
   117  	}
   118  
   119  	return &egressInternalServer{
   120  		svc: svc,
   121  		rpc: s,
   122  	}, nil
   123  }
   124  
   125  func (s *egressInternalServer) RegisterStartEgressTopic(topic string) error {
   126  	return server.RegisterHandler(s.rpc, "StartEgress", []string{topic}, s.svc.StartEgress, s.svc.StartEgressAffinity)
   127  }
   128  
   129  func (s *egressInternalServer) DeregisterStartEgressTopic(topic string) {
   130  	s.rpc.DeregisterHandler("StartEgress", []string{topic})
   131  }
   132  
   133  func (s *egressInternalServer) Shutdown() {
   134  	s.rpc.Close(false)
   135  }
   136  
   137  func (s *egressInternalServer) Kill() {
   138  	s.rpc.Close(true)
   139  }
   140  
   141  // ==============================
   142  // EgressHandler Client Interface
   143  // ==============================
   144  
   145  type EgressHandlerClient interface {
   146  	UpdateStream(ctx context.Context, topic string, req *livekit1.UpdateStreamRequest, opts ...psrpc.RequestOption) (*livekit1.EgressInfo, error)
   147  
   148  	StopEgress(ctx context.Context, topic string, req *livekit1.StopEgressRequest, opts ...psrpc.RequestOption) (*livekit1.EgressInfo, error)
   149  }
   150  
   151  // ==================================
   152  // EgressHandler ServerImpl Interface
   153  // ==================================
   154  
   155  type EgressHandlerServerImpl interface {
   156  	UpdateStream(context.Context, *livekit1.UpdateStreamRequest) (*livekit1.EgressInfo, error)
   157  
   158  	StopEgress(context.Context, *livekit1.StopEgressRequest) (*livekit1.EgressInfo, error)
   159  }
   160  
   161  // ==============================
   162  // EgressHandler Server Interface
   163  // ==============================
   164  
   165  type EgressHandlerServer interface {
   166  	RegisterUpdateStreamTopic(topic string) error
   167  	DeregisterUpdateStreamTopic(topic string)
   168  	RegisterStopEgressTopic(topic string) error
   169  	DeregisterStopEgressTopic(topic string)
   170  
   171  	// Close and wait for pending RPCs to complete
   172  	Shutdown()
   173  
   174  	// Close immediately, without waiting for pending RPCs
   175  	Kill()
   176  }
   177  
   178  // ====================
   179  // EgressHandler Client
   180  // ====================
   181  
   182  type egressHandlerClient struct {
   183  	client *client.RPCClient
   184  }
   185  
   186  // NewEgressHandlerClient creates a psrpc client that implements the EgressHandlerClient interface.
   187  func NewEgressHandlerClient(clientID string, bus psrpc.MessageBus, opts ...psrpc.ClientOption) (EgressHandlerClient, error) {
   188  	sd := &info.ServiceDefinition{
   189  		Name: "EgressHandler",
   190  		ID:   clientID,
   191  	}
   192  
   193  	sd.RegisterMethod("UpdateStream", false, false, true)
   194  	sd.RegisterMethod("StopEgress", false, false, true)
   195  
   196  	rpcClient, err := client.NewRPCClient(sd, bus, opts...)
   197  	if err != nil {
   198  		return nil, err
   199  	}
   200  
   201  	return &egressHandlerClient{
   202  		client: rpcClient,
   203  	}, nil
   204  }
   205  
   206  func (c *egressHandlerClient) UpdateStream(ctx context.Context, topic string, req *livekit1.UpdateStreamRequest, opts ...psrpc.RequestOption) (*livekit1.EgressInfo, error) {
   207  	return client.RequestSingle[*livekit1.EgressInfo](ctx, c.client, "UpdateStream", []string{topic}, req, opts...)
   208  }
   209  
   210  func (c *egressHandlerClient) StopEgress(ctx context.Context, topic string, req *livekit1.StopEgressRequest, opts ...psrpc.RequestOption) (*livekit1.EgressInfo, error) {
   211  	return client.RequestSingle[*livekit1.EgressInfo](ctx, c.client, "StopEgress", []string{topic}, req, opts...)
   212  }
   213  
   214  // ====================
   215  // EgressHandler Server
   216  // ====================
   217  
   218  type egressHandlerServer struct {
   219  	svc EgressHandlerServerImpl
   220  	rpc *server.RPCServer
   221  }
   222  
   223  // NewEgressHandlerServer builds a RPCServer that will route requests
   224  // to the corresponding method in the provided svc implementation.
   225  func NewEgressHandlerServer(serverID string, svc EgressHandlerServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (EgressHandlerServer, error) {
   226  	sd := &info.ServiceDefinition{
   227  		Name: "EgressHandler",
   228  		ID:   serverID,
   229  	}
   230  
   231  	s := server.NewRPCServer(sd, bus, opts...)
   232  
   233  	sd.RegisterMethod("UpdateStream", false, false, true)
   234  	sd.RegisterMethod("StopEgress", false, false, true)
   235  	return &egressHandlerServer{
   236  		svc: svc,
   237  		rpc: s,
   238  	}, nil
   239  }
   240  
   241  func (s *egressHandlerServer) RegisterUpdateStreamTopic(topic string) error {
   242  	return server.RegisterHandler(s.rpc, "UpdateStream", []string{topic}, s.svc.UpdateStream, nil)
   243  }
   244  
   245  func (s *egressHandlerServer) DeregisterUpdateStreamTopic(topic string) {
   246  	s.rpc.DeregisterHandler("UpdateStream", []string{topic})
   247  }
   248  
   249  func (s *egressHandlerServer) RegisterStopEgressTopic(topic string) error {
   250  	return server.RegisterHandler(s.rpc, "StopEgress", []string{topic}, s.svc.StopEgress, nil)
   251  }
   252  
   253  func (s *egressHandlerServer) DeregisterStopEgressTopic(topic string) {
   254  	s.rpc.DeregisterHandler("StopEgress", []string{topic})
   255  }
   256  
   257  func (s *egressHandlerServer) Shutdown() {
   258  	s.rpc.Close(false)
   259  }
   260  
   261  func (s *egressHandlerServer) Kill() {
   262  	s.rpc.Close(true)
   263  }
   264  
   265  var psrpcFileDescriptor0 = []byte{
   266  	// 470 bytes of a gzipped FileDescriptorProto
   267  	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xd1, 0x8e, 0xd2, 0x40,
   268  	0x14, 0x86, 0x1d, 0x2b, 0x85, 0x1e, 0x04, 0x37, 0xe3, 0x1a, 0x66, 0xbb, 0xbb, 0x09, 0xa9, 0x5e,
   269  	0x10, 0xa3, 0x25, 0x61, 0xaf, 0xbc, 0x74, 0x0d, 0xc9, 0x92, 0x6c, 0x62, 0x52, 0xdc, 0x6c, 0xe2,
   270  	0x0d, 0x29, 0xed, 0x88, 0x13, 0xda, 0xce, 0x38, 0x33, 0xc0, 0x13, 0x78, 0xb1, 0x8f, 0xe1, 0x1b,
   271  	0x98, 0x7d, 0x42, 0xc3, 0x0c, 0xd4, 0x02, 0xc1, 0x78, 0xd5, 0xcc, 0xff, 0xff, 0xe7, 0xeb, 0x99,
   272  	0x73, 0x5a, 0x38, 0x91, 0x22, 0xe9, 0xd3, 0x99, 0xa4, 0x4a, 0x85, 0x42, 0x72, 0xcd, 0xb1, 0x23,
   273  	0x45, 0xe2, 0xb7, 0xb8, 0xd0, 0x8c, 0x17, 0x1b, 0xcd, 0x3f, 0xcd, 0xd8, 0x92, 0xce, 0x99, 0x9e,
   274  	0x54, 0x93, 0xc1, 0x4f, 0x07, 0xf0, 0x58, 0xc7, 0x52, 0x0f, 0x8d, 0x1a, 0xd1, 0x1f, 0x0b, 0xaa,
   275  	0x34, 0x3e, 0x07, 0xcf, 0xc6, 0x26, 0x2c, 0x25, 0xa8, 0x8b, 0x7a, 0x5e, 0xd4, 0xb0, 0xc2, 0x28,
   276  	0xc5, 0xb7, 0xd0, 0x96, 0x9c, 0xe7, 0x93, 0x84, 0xe7, 0x82, 0x2b, 0xa6, 0x29, 0xa9, 0x75, 0x51,
   277  	0xaf, 0x39, 0x78, 0x1d, 0x6e, 0x5e, 0x11, 0x46, 0x9c, 0xe7, 0x9f, 0xb6, 0xee, 0x0e, 0xf9, 0xe6,
   278  	0x49, 0xd4, 0x92, 0x55, 0x17, 0x7f, 0x86, 0x17, 0x5a, 0xc6, 0xc9, 0xbc, 0x82, 0x73, 0x0d, 0xee,
   279  	0x4d, 0x89, 0xfb, 0xb2, 0xf6, 0x8f, 0xf2, 0xda, 0x7a, 0xc7, 0xc6, 0x57, 0x50, 0x33, 0x0a, 0xa9,
   280  	0x1b, 0xcc, 0xf9, 0x2e, 0x66, 0xbf, 0xda, 0x66, 0xf1, 0x7b, 0x70, 0x56, 0x74, 0x4a, 0x9a, 0xa6,
   281  	0xe4, 0xac, 0x2c, 0xb9, 0xa7, 0xd3, 0xfd, 0x82, 0x75, 0x0e, 0x77, 0xa0, 0x6e, 0x46, 0xc0, 0x52,
   282  	0xe2, 0x98, 0xe9, 0xb8, 0xeb, 0xe3, 0x28, 0xc5, 0xa7, 0x50, 0xd3, 0x7c, 0x4e, 0x0b, 0xd2, 0x30,
   283  	0xb2, 0x3d, 0xe0, 0x57, 0xe0, 0xae, 0xd4, 0x64, 0x21, 0x33, 0xe2, 0x59, 0x79, 0xa5, 0xee, 0x64,
   284  	0x76, 0xed, 0x41, 0x5d, 0x5a, 0x6e, 0x70, 0x06, 0x9d, 0x5b, 0xa6, 0xf4, 0xc7, 0x44, 0xb3, 0xe5,
   285  	0xee, 0x0d, 0x83, 0x0f, 0x40, 0x0e, 0x2d, 0x25, 0x78, 0xa1, 0x28, 0xbe, 0x04, 0x28, 0xf7, 0xa4,
   286  	0x08, 0xea, 0x3a, 0x3d, 0x2f, 0xf2, 0xb6, 0x8b, 0x52, 0x83, 0xdf, 0x08, 0xda, 0xb6, 0x62, 0x54,
   287  	0x68, 0x2a, 0x8b, 0x38, 0xc3, 0x43, 0x68, 0x56, 0xf6, 0x8d, 0x3b, 0xa1, 0x14, 0x49, 0x78, 0xf8,
   288  	0x05, 0xf8, 0x2f, 0xcb, 0x19, 0x6c, 0x01, 0xdf, 0x78, 0xd0, 0x78, 0x7c, 0x40, 0xcf, 0x08, 0xea,
   289  	0x21, 0x7c, 0x0f, 0x27, 0xfb, 0x4d, 0xe1, 0x0b, 0xc3, 0x3a, 0x72, 0x0d, 0xff, 0xf2, 0x88, 0x6b,
   290  	0x6f, 0x12, 0xb8, 0x8f, 0x0f, 0xe8, 0x69, 0x03, 0x0d, 0x7e, 0x21, 0x68, 0x59, 0xeb, 0x26, 0x2e,
   291  	0xd2, 0x8c, 0x4a, 0x3c, 0x82, 0xe7, 0x77, 0x22, 0x8d, 0x35, 0x1d, 0x6b, 0x49, 0xe3, 0x1c, 0x5f,
   292  	0x94, 0x9d, 0x55, 0xe5, 0x7f, 0xf6, 0x6d, 0xe0, 0x04, 0xe1, 0x21, 0xc0, 0x58, 0x73, 0xb1, 0xe9,
   293  	0xd7, 0x2f, 0xa3, 0x7f, 0xc5, 0xff, 0xc1, 0x5c, 0xbf, 0xfb, 0xfa, 0x76, 0xc6, 0xf4, 0xf7, 0xc5,
   294  	0x34, 0x4c, 0x78, 0xde, 0xdf, 0x04, 0xcb, 0xa7, 0x98, 0xcf, 0xfa, 0x8a, 0xca, 0x25, 0x4b, 0x68,
   295  	0x5f, 0x8a, 0x64, 0xea, 0x9a, 0x3f, 0xed, 0xea, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xca, 0xcb,
   296  	0x2a, 0x09, 0xa7, 0x03, 0x00, 0x00,
   297  }