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

     1  // Code generated by protoc-gen-psrpc v0.3.0, DO NOT EDIT.
     2  // source: rpc/ingress.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 google_protobuf2 "google.golang.org/protobuf/types/known/emptypb"
    16  import livekit2 "github.com/whoyao/protocol/livekit"
    17  
    18  var _ = version.PsrpcVersion_0_3_0
    19  
    20  // ================================
    21  // IngressInternal Client Interface
    22  // ================================
    23  
    24  type IngressInternalClient interface {
    25  	ListActiveIngress(ctx context.Context, req *ListActiveIngressRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*ListActiveIngressResponse], error)
    26  }
    27  
    28  // ====================================
    29  // IngressInternal ServerImpl Interface
    30  // ====================================
    31  
    32  type IngressInternalServerImpl interface {
    33  	ListActiveIngress(context.Context, *ListActiveIngressRequest) (*ListActiveIngressResponse, error)
    34  }
    35  
    36  // ================================
    37  // IngressInternal Server Interface
    38  // ================================
    39  
    40  type IngressInternalServer interface {
    41  
    42  	// Close and wait for pending RPCs to complete
    43  	Shutdown()
    44  
    45  	// Close immediately, without waiting for pending RPCs
    46  	Kill()
    47  }
    48  
    49  // ======================
    50  // IngressInternal Client
    51  // ======================
    52  
    53  type ingressInternalClient struct {
    54  	client *client.RPCClient
    55  }
    56  
    57  // NewIngressInternalClient creates a psrpc client that implements the IngressInternalClient interface.
    58  func NewIngressInternalClient(clientID string, bus psrpc.MessageBus, opts ...psrpc.ClientOption) (IngressInternalClient, error) {
    59  	sd := &info.ServiceDefinition{
    60  		Name: "IngressInternal",
    61  		ID:   clientID,
    62  	}
    63  
    64  	sd.RegisterMethod("ListActiveIngress", false, true, false)
    65  
    66  	rpcClient, err := client.NewRPCClient(sd, bus, opts...)
    67  	if err != nil {
    68  		return nil, err
    69  	}
    70  
    71  	return &ingressInternalClient{
    72  		client: rpcClient,
    73  	}, nil
    74  }
    75  
    76  func (c *ingressInternalClient) ListActiveIngress(ctx context.Context, req *ListActiveIngressRequest, opts ...psrpc.RequestOption) (<-chan *psrpc.Response[*ListActiveIngressResponse], error) {
    77  	return client.RequestMulti[*ListActiveIngressResponse](ctx, c.client, "ListActiveIngress", nil, req, opts...)
    78  }
    79  
    80  // ======================
    81  // IngressInternal Server
    82  // ======================
    83  
    84  type ingressInternalServer struct {
    85  	svc IngressInternalServerImpl
    86  	rpc *server.RPCServer
    87  }
    88  
    89  // NewIngressInternalServer builds a RPCServer that will route requests
    90  // to the corresponding method in the provided svc implementation.
    91  func NewIngressInternalServer(serverID string, svc IngressInternalServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (IngressInternalServer, error) {
    92  	sd := &info.ServiceDefinition{
    93  		Name: "IngressInternal",
    94  		ID:   serverID,
    95  	}
    96  
    97  	s := server.NewRPCServer(sd, bus, opts...)
    98  
    99  	sd.RegisterMethod("ListActiveIngress", false, true, false)
   100  	var err error
   101  	err = server.RegisterHandler(s, "ListActiveIngress", nil, svc.ListActiveIngress, nil)
   102  	if err != nil {
   103  		s.Close(false)
   104  		return nil, err
   105  	}
   106  
   107  	return &ingressInternalServer{
   108  		svc: svc,
   109  		rpc: s,
   110  	}, nil
   111  }
   112  
   113  func (s *ingressInternalServer) Shutdown() {
   114  	s.rpc.Close(false)
   115  }
   116  
   117  func (s *ingressInternalServer) Kill() {
   118  	s.rpc.Close(true)
   119  }
   120  
   121  // ===============================
   122  // IngressHandler Client Interface
   123  // ===============================
   124  
   125  type IngressHandlerClient interface {
   126  	UpdateIngress(ctx context.Context, topic string, req *livekit2.UpdateIngressRequest, opts ...psrpc.RequestOption) (*livekit2.IngressState, error)
   127  
   128  	DeleteIngress(ctx context.Context, topic string, req *livekit2.DeleteIngressRequest, opts ...psrpc.RequestOption) (*livekit2.IngressState, error)
   129  
   130  	DeleteWHIPResource(ctx context.Context, topic string, req *DeleteWHIPResourceRequest, opts ...psrpc.RequestOption) (*google_protobuf2.Empty, error)
   131  }
   132  
   133  // ===================================
   134  // IngressHandler ServerImpl Interface
   135  // ===================================
   136  
   137  type IngressHandlerServerImpl interface {
   138  	UpdateIngress(context.Context, *livekit2.UpdateIngressRequest) (*livekit2.IngressState, error)
   139  
   140  	DeleteIngress(context.Context, *livekit2.DeleteIngressRequest) (*livekit2.IngressState, error)
   141  
   142  	DeleteWHIPResource(context.Context, *DeleteWHIPResourceRequest) (*google_protobuf2.Empty, error)
   143  }
   144  
   145  // ===============================
   146  // IngressHandler Server Interface
   147  // ===============================
   148  
   149  type IngressHandlerServer interface {
   150  	RegisterUpdateIngressTopic(topic string) error
   151  	DeregisterUpdateIngressTopic(topic string)
   152  	RegisterDeleteIngressTopic(topic string) error
   153  	DeregisterDeleteIngressTopic(topic string)
   154  	RegisterDeleteWHIPResourceTopic(topic string) error
   155  	DeregisterDeleteWHIPResourceTopic(topic string)
   156  
   157  	// Close and wait for pending RPCs to complete
   158  	Shutdown()
   159  
   160  	// Close immediately, without waiting for pending RPCs
   161  	Kill()
   162  }
   163  
   164  // =====================
   165  // IngressHandler Client
   166  // =====================
   167  
   168  type ingressHandlerClient struct {
   169  	client *client.RPCClient
   170  }
   171  
   172  // NewIngressHandlerClient creates a psrpc client that implements the IngressHandlerClient interface.
   173  func NewIngressHandlerClient(clientID string, bus psrpc.MessageBus, opts ...psrpc.ClientOption) (IngressHandlerClient, error) {
   174  	sd := &info.ServiceDefinition{
   175  		Name: "IngressHandler",
   176  		ID:   clientID,
   177  	}
   178  
   179  	sd.RegisterMethod("UpdateIngress", false, false, true)
   180  	sd.RegisterMethod("DeleteIngress", false, false, true)
   181  	sd.RegisterMethod("DeleteWHIPResource", false, false, true)
   182  
   183  	rpcClient, err := client.NewRPCClient(sd, bus, opts...)
   184  	if err != nil {
   185  		return nil, err
   186  	}
   187  
   188  	return &ingressHandlerClient{
   189  		client: rpcClient,
   190  	}, nil
   191  }
   192  
   193  func (c *ingressHandlerClient) UpdateIngress(ctx context.Context, topic string, req *livekit2.UpdateIngressRequest, opts ...psrpc.RequestOption) (*livekit2.IngressState, error) {
   194  	return client.RequestSingle[*livekit2.IngressState](ctx, c.client, "UpdateIngress", []string{topic}, req, opts...)
   195  }
   196  
   197  func (c *ingressHandlerClient) DeleteIngress(ctx context.Context, topic string, req *livekit2.DeleteIngressRequest, opts ...psrpc.RequestOption) (*livekit2.IngressState, error) {
   198  	return client.RequestSingle[*livekit2.IngressState](ctx, c.client, "DeleteIngress", []string{topic}, req, opts...)
   199  }
   200  
   201  func (c *ingressHandlerClient) DeleteWHIPResource(ctx context.Context, topic string, req *DeleteWHIPResourceRequest, opts ...psrpc.RequestOption) (*google_protobuf2.Empty, error) {
   202  	return client.RequestSingle[*google_protobuf2.Empty](ctx, c.client, "DeleteWHIPResource", []string{topic}, req, opts...)
   203  }
   204  
   205  // =====================
   206  // IngressHandler Server
   207  // =====================
   208  
   209  type ingressHandlerServer struct {
   210  	svc IngressHandlerServerImpl
   211  	rpc *server.RPCServer
   212  }
   213  
   214  // NewIngressHandlerServer builds a RPCServer that will route requests
   215  // to the corresponding method in the provided svc implementation.
   216  func NewIngressHandlerServer(serverID string, svc IngressHandlerServerImpl, bus psrpc.MessageBus, opts ...psrpc.ServerOption) (IngressHandlerServer, error) {
   217  	sd := &info.ServiceDefinition{
   218  		Name: "IngressHandler",
   219  		ID:   serverID,
   220  	}
   221  
   222  	s := server.NewRPCServer(sd, bus, opts...)
   223  
   224  	sd.RegisterMethod("UpdateIngress", false, false, true)
   225  	sd.RegisterMethod("DeleteIngress", false, false, true)
   226  	sd.RegisterMethod("DeleteWHIPResource", false, false, true)
   227  	return &ingressHandlerServer{
   228  		svc: svc,
   229  		rpc: s,
   230  	}, nil
   231  }
   232  
   233  func (s *ingressHandlerServer) RegisterUpdateIngressTopic(topic string) error {
   234  	return server.RegisterHandler(s.rpc, "UpdateIngress", []string{topic}, s.svc.UpdateIngress, nil)
   235  }
   236  
   237  func (s *ingressHandlerServer) DeregisterUpdateIngressTopic(topic string) {
   238  	s.rpc.DeregisterHandler("UpdateIngress", []string{topic})
   239  }
   240  
   241  func (s *ingressHandlerServer) RegisterDeleteIngressTopic(topic string) error {
   242  	return server.RegisterHandler(s.rpc, "DeleteIngress", []string{topic}, s.svc.DeleteIngress, nil)
   243  }
   244  
   245  func (s *ingressHandlerServer) DeregisterDeleteIngressTopic(topic string) {
   246  	s.rpc.DeregisterHandler("DeleteIngress", []string{topic})
   247  }
   248  
   249  func (s *ingressHandlerServer) RegisterDeleteWHIPResourceTopic(topic string) error {
   250  	return server.RegisterHandler(s.rpc, "DeleteWHIPResource", []string{topic}, s.svc.DeleteWHIPResource, nil)
   251  }
   252  
   253  func (s *ingressHandlerServer) DeregisterDeleteWHIPResourceTopic(topic string) {
   254  	s.rpc.DeregisterHandler("DeleteWHIPResource", []string{topic})
   255  }
   256  
   257  func (s *ingressHandlerServer) Shutdown() {
   258  	s.rpc.Close(false)
   259  }
   260  
   261  func (s *ingressHandlerServer) Kill() {
   262  	s.rpc.Close(true)
   263  }
   264  
   265  var psrpcFileDescriptor1 = []byte{
   266  	// 340 bytes of a gzipped FileDescriptorProto
   267  	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x4a, 0xc3, 0x40,
   268  	0x14, 0x24, 0x2d, 0x14, 0x5d, 0xa9, 0xd2, 0x85, 0x4a, 0x8c, 0xa8, 0xa5, 0x27, 0x11, 0xd9, 0x40,
   269  	0xbd, 0x7a, 0x51, 0x14, 0x1a, 0x50, 0x90, 0xaa, 0x08, 0xbd, 0x94, 0x74, 0xf3, 0x8c, 0x4b, 0xd3,
   270  	0xec, 0xba, 0xfb, 0x52, 0xf0, 0xee, 0xc5, 0xdf, 0xf1, 0x0b, 0x25, 0xdd, 0x4d, 0xb1, 0xd4, 0x80,
   271  	0xa7, 0x90, 0x99, 0x9d, 0x99, 0xf7, 0x86, 0x47, 0x3a, 0x5a, 0xf1, 0x50, 0xe4, 0xa9, 0x06, 0x63,
   272  	0x98, 0xd2, 0x12, 0x25, 0x6d, 0x6a, 0xc5, 0x83, 0xb6, 0x54, 0x28, 0x64, 0xee, 0xb0, 0xa0, 0x9b,
   273  	0x89, 0x05, 0xcc, 0x04, 0x4e, 0xd6, 0x9e, 0x06, 0x87, 0xa9, 0x94, 0x69, 0x06, 0xe1, 0xf2, 0x6f,
   274  	0x5a, 0xbc, 0x86, 0x30, 0x57, 0xf8, 0x61, 0xc9, 0x7e, 0x40, 0xfc, 0x3b, 0x61, 0xf0, 0x8a, 0xa3,
   275  	0x58, 0x40, 0x64, 0x75, 0x23, 0x78, 0x2f, 0xc0, 0x60, 0xff, 0x92, 0x1c, 0xfc, 0xc1, 0x19, 0x25,
   276  	0x73, 0x03, 0xf4, 0x84, 0xec, 0xb8, 0x98, 0x89, 0x48, 0x8c, 0xef, 0xf5, 0x9a, 0xa7, 0xdb, 0x23,
   277  	0xe2, 0xa0, 0x28, 0x31, 0xa5, 0xfa, 0x06, 0x32, 0x40, 0x78, 0x19, 0x46, 0x0f, 0x23, 0x30, 0xb2,
   278  	0xd0, 0x1c, 0x9c, 0x75, 0xa9, 0xd6, 0x0e, 0x9a, 0x88, 0xc4, 0xf7, 0x7a, 0x5e, 0xa9, 0xae, 0xa0,
   279  	0x28, 0x19, 0xcc, 0xc9, 0x9e, 0x4b, 0x8c, 0x72, 0x04, 0x9d, 0xc7, 0x19, 0x1d, 0x93, 0xce, 0xc6,
   280  	0x38, 0xf4, 0x88, 0x69, 0xc5, 0x59, 0xdd, 0x0a, 0xc1, 0x71, 0x1d, 0x6d, 0xb7, 0xe8, 0xb7, 0xbe,
   281  	0xbf, 0xbc, 0xc6, 0x96, 0x37, 0xf8, 0x6c, 0x90, 0x5d, 0xc7, 0x0d, 0xe3, 0x3c, 0xc9, 0x40, 0xd3,
   282  	0x7b, 0xd2, 0x7e, 0x56, 0x49, 0x8c, 0xbf, 0xa2, 0x5c, 0xbf, 0x6c, 0x0d, 0xaf, 0xa2, 0xba, 0x2b,
   283  	0xda, 0x11, 0x8f, 0x18, 0xa3, 0x4b, 0xf0, 0xbd, 0xd2, 0xce, 0xd6, 0xb1, 0x69, 0xb7, 0x86, 0xff,
   284  	0xd3, 0xee, 0x89, 0xd0, 0xcd, 0x76, 0xa9, 0x5d, 0xb7, 0xb6, 0xf6, 0x60, 0x9f, 0xd9, 0x5b, 0x60,
   285  	0xd5, 0x2d, 0xb0, 0xdb, 0xf2, 0x16, 0x2a, 0xd7, 0xeb, 0xf3, 0xf1, 0x59, 0x2a, 0xf0, 0xad, 0x98,
   286  	0x32, 0x2e, 0xe7, 0xa1, 0x1b, 0x60, 0xf5, 0x55, 0xb3, 0x34, 0x34, 0xa0, 0x17, 0x82, 0x43, 0xa8,
   287  	0x15, 0x9f, 0xb6, 0x96, 0x2e, 0x17, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x97, 0xf5, 0xcc,
   288  	0x9f, 0x02, 0x00, 0x00,
   289  }