Updated egress rpc (#1252)
* updated egress rpc * check if egress exists on stop * fix static check * remove old migration code * rename * regenerate, update test * latest staticcheck * update to psrpc 0.1.0 * fix tests * dual write rpcs on running egress * remove unused field * fix race, change service for egress impl * return nil if bus is nil * id -> ids * add affinityFunc to StartEgress
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
// Code generated by protoc-gen-psrpc v0.1.0, DO NOT EDIT.
|
||||
// source: pkg/service/rpc/egress.proto
|
||||
|
||||
package rpc
|
||||
|
||||
import context "context"
|
||||
|
||||
import psrpc1 "github.com/livekit/psrpc"
|
||||
import livekit "github.com/livekit/protocol/livekit"
|
||||
import livekit3 "github.com/livekit/protocol/livekit"
|
||||
|
||||
// ===============================
|
||||
// EgressInternal Client Interface
|
||||
// ===============================
|
||||
|
||||
type EgressInternalClient interface {
|
||||
StartEgress(context.Context, *livekit3.StartEgressRequest, ...psrpc1.RequestOpt) (*livekit.EgressInfo, error)
|
||||
|
||||
ListActiveEgress(context.Context, *ListActiveEgressRequest, ...psrpc1.RequestOpt) (<-chan *psrpc1.Response[*ListActiveEgressResponse], error)
|
||||
}
|
||||
|
||||
// ===================================
|
||||
// EgressInternal ServerImpl Interface
|
||||
// ===================================
|
||||
|
||||
type EgressInternalServerImpl interface {
|
||||
StartEgress(context.Context, *livekit3.StartEgressRequest) (*livekit.EgressInfo, error)
|
||||
StartEgressAffinity(*livekit3.StartEgressRequest) float32
|
||||
|
||||
ListActiveEgress(context.Context, *ListActiveEgressRequest) (*ListActiveEgressResponse, error)
|
||||
}
|
||||
|
||||
// ===============================
|
||||
// EgressInternal Server Interface
|
||||
// ===============================
|
||||
|
||||
type EgressInternalServer interface {
|
||||
}
|
||||
|
||||
// =====================
|
||||
// EgressInternal Client
|
||||
// =====================
|
||||
|
||||
type egressInternalClient struct {
|
||||
client psrpc1.RPCClient
|
||||
}
|
||||
|
||||
// NewEgressInternalClient creates a psrpc client that implements the EgressInternalClient interface.
|
||||
func NewEgressInternalClient(clientID string, bus psrpc1.MessageBus, opts ...psrpc1.ClientOpt) (EgressInternalClient, error) {
|
||||
rpcClient, err := psrpc1.NewRPCClient("EgressInternal", clientID, bus, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &egressInternalClient{
|
||||
client: rpcClient,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *egressInternalClient) StartEgress(ctx context.Context, req *livekit3.StartEgressRequest, opts ...psrpc1.RequestOpt) (*livekit.EgressInfo, error) {
|
||||
return psrpc1.RequestTopicSingle[*livekit.EgressInfo](ctx, c.client, "StartEgress", "", req, opts...)
|
||||
}
|
||||
|
||||
func (c *egressInternalClient) ListActiveEgress(ctx context.Context, req *ListActiveEgressRequest, opts ...psrpc1.RequestOpt) (<-chan *psrpc1.Response[*ListActiveEgressResponse], error) {
|
||||
return psrpc1.RequestTopicAll[*ListActiveEgressResponse](ctx, c.client, "ListActiveEgress", "", req, opts...)
|
||||
}
|
||||
|
||||
// =====================
|
||||
// EgressInternal Server
|
||||
// =====================
|
||||
|
||||
type egressInternalServer struct {
|
||||
svc EgressInternalServerImpl
|
||||
rpc psrpc1.RPCServer
|
||||
}
|
||||
|
||||
// NewEgressInternalServer builds a RPCServer that can be used to handle
|
||||
// requests that are routed to the right method in the provided svc implementation.
|
||||
func NewEgressInternalServer(serverID string, svc EgressInternalServerImpl, bus psrpc1.MessageBus, opts ...psrpc1.ServerOpt) (EgressInternalServer, error) {
|
||||
rpcServer := psrpc1.NewRPCServer("EgressInternal", serverID, bus, opts...)
|
||||
|
||||
var err error
|
||||
err = rpcServer.RegisterHandler(psrpc1.NewHandlerWithAffinity("StartEgress", svc.StartEgress, svc.StartEgressAffinity))
|
||||
if err != nil {
|
||||
rpcServer.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = rpcServer.RegisterHandler(psrpc1.NewHandler("ListActiveEgress", svc.ListActiveEgress))
|
||||
if err != nil {
|
||||
rpcServer.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &egressInternalServer{
|
||||
svc: svc,
|
||||
rpc: rpcServer,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// EgressHandler Client Interface
|
||||
// ==============================
|
||||
|
||||
type EgressHandlerClient interface {
|
||||
UpdateStream(context.Context, string, *livekit.UpdateStreamRequest, ...psrpc1.RequestOpt) (*livekit.EgressInfo, error)
|
||||
|
||||
StopEgress(context.Context, string, *livekit.StopEgressRequest, ...psrpc1.RequestOpt) (*livekit.EgressInfo, error)
|
||||
|
||||
SubscribeInfoUpdate(context.Context) (psrpc1.Subscription[*livekit.EgressInfo], error)
|
||||
}
|
||||
|
||||
// ==================================
|
||||
// EgressHandler ServerImpl Interface
|
||||
// ==================================
|
||||
|
||||
type EgressHandlerServerImpl interface {
|
||||
UpdateStream(context.Context, *livekit.UpdateStreamRequest) (*livekit.EgressInfo, error)
|
||||
|
||||
StopEgress(context.Context, *livekit.StopEgressRequest) (*livekit.EgressInfo, error)
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// EgressHandler Server Interface
|
||||
// ==============================
|
||||
|
||||
type EgressHandlerServer interface {
|
||||
RegisterUpdateStreamTopic(string) error
|
||||
DeregisterUpdateStreamTopic(string) error
|
||||
|
||||
RegisterStopEgressTopic(string) error
|
||||
DeregisterStopEgressTopic(string) error
|
||||
|
||||
PublishInfoUpdate(context.Context, *livekit.EgressInfo) error
|
||||
}
|
||||
|
||||
// ====================
|
||||
// EgressHandler Client
|
||||
// ====================
|
||||
|
||||
type egressHandlerClient struct {
|
||||
client psrpc1.RPCClient
|
||||
}
|
||||
|
||||
// NewEgressHandlerClient creates a psrpc client that implements the EgressHandlerClient interface.
|
||||
func NewEgressHandlerClient(clientID string, bus psrpc1.MessageBus, opts ...psrpc1.ClientOpt) (EgressHandlerClient, error) {
|
||||
rpcClient, err := psrpc1.NewRPCClient("EgressHandler", clientID, bus, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &egressHandlerClient{
|
||||
client: rpcClient,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *egressHandlerClient) UpdateStream(ctx context.Context, topic string, req *livekit.UpdateStreamRequest, opts ...psrpc1.RequestOpt) (*livekit.EgressInfo, error) {
|
||||
return psrpc1.RequestTopicSingle[*livekit.EgressInfo](ctx, c.client, "UpdateStream", topic, req, opts...)
|
||||
}
|
||||
|
||||
func (c *egressHandlerClient) StopEgress(ctx context.Context, topic string, req *livekit.StopEgressRequest, opts ...psrpc1.RequestOpt) (*livekit.EgressInfo, error) {
|
||||
return psrpc1.RequestTopicSingle[*livekit.EgressInfo](ctx, c.client, "StopEgress", topic, req, opts...)
|
||||
}
|
||||
|
||||
func (c *egressHandlerClient) SubscribeInfoUpdate(ctx context.Context) (psrpc1.Subscription[*livekit.EgressInfo], error) {
|
||||
return psrpc1.SubscribeTopicQueue[*livekit.EgressInfo](ctx, c.client, "InfoUpdate", "")
|
||||
}
|
||||
|
||||
// ====================
|
||||
// EgressHandler Server
|
||||
// ====================
|
||||
|
||||
type egressHandlerServer struct {
|
||||
svc EgressHandlerServerImpl
|
||||
rpc psrpc1.RPCServer
|
||||
}
|
||||
|
||||
// NewEgressHandlerServer builds a RPCServer that can be used to handle
|
||||
// requests that are routed to the right method in the provided svc implementation.
|
||||
func NewEgressHandlerServer(serverID string, svc EgressHandlerServerImpl, bus psrpc1.MessageBus, opts ...psrpc1.ServerOpt) (EgressHandlerServer, error) {
|
||||
rpcServer := psrpc1.NewRPCServer("EgressHandler", serverID, bus, opts...)
|
||||
|
||||
return &egressHandlerServer{
|
||||
svc: svc,
|
||||
rpc: rpcServer,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *egressHandlerServer) RegisterUpdateStreamTopic(topic string) error {
|
||||
return s.rpc.RegisterHandler(psrpc1.NewTopicHandler("UpdateStream", topic, s.svc.UpdateStream))
|
||||
}
|
||||
|
||||
func (s *egressHandlerServer) DeregisterUpdateStreamTopic(topic string) error {
|
||||
return s.rpc.DeregisterTopic("UpdateStream", topic)
|
||||
}
|
||||
|
||||
func (s *egressHandlerServer) RegisterStopEgressTopic(topic string) error {
|
||||
return s.rpc.RegisterHandler(psrpc1.NewTopicHandler("StopEgress", topic, s.svc.StopEgress))
|
||||
}
|
||||
|
||||
func (s *egressHandlerServer) DeregisterStopEgressTopic(topic string) error {
|
||||
return s.rpc.DeregisterTopic("StopEgress", topic)
|
||||
}
|
||||
|
||||
func (s *egressHandlerServer) PublishInfoUpdate(ctx context.Context, msg *livekit.EgressInfo) error {
|
||||
return s.rpc.PublishTopic(ctx, "InfoUpdate", "", msg)
|
||||
}
|
||||
|
||||
var psrpcFileDescriptor0 = []byte{
|
||||
// 329 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xd1, 0x4a, 0x02, 0x41,
|
||||
0x14, 0x65, 0x92, 0x2c, 0x6f, 0x19, 0x32, 0x05, 0xd9, 0xa6, 0x20, 0xfb, 0x14, 0x11, 0xbb, 0x60,
|
||||
0xf4, 0xd0, 0x63, 0x81, 0x94, 0xd0, 0x93, 0x12, 0x41, 0x2f, 0xb2, 0xce, 0xde, 0x6c, 0x50, 0x77,
|
||||
0xa6, 0x99, 0xab, 0xd0, 0x27, 0xf4, 0x3b, 0x7e, 0x4d, 0x9f, 0x13, 0xed, 0x8c, 0xb2, 0x18, 0x56,
|
||||
0x4f, 0xc3, 0x9c, 0x73, 0xef, 0xb9, 0xe7, 0x70, 0x2f, 0x34, 0xf4, 0x78, 0x14, 0x5b, 0x34, 0x73,
|
||||
0x29, 0x30, 0x36, 0x5a, 0xc4, 0x38, 0x32, 0x68, 0x6d, 0xa4, 0x8d, 0x22, 0xc5, 0x4b, 0x46, 0x8b,
|
||||
0xa0, 0xaa, 0x34, 0x49, 0x95, 0x79, 0x2c, 0x08, 0x26, 0x72, 0x8e, 0x63, 0x49, 0x03, 0xa3, 0xc5,
|
||||
0x40,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 0x8b,
|
||||
0xfc, 0xa5, 0xad, 0xc6, 0x6e, 0x2f, 0x9e, 0xcf, 0x47, 0x92, 0x5e, 0x67, 0xc3, 0x48, 0xa8, 0x69,
|
||||
0xec, 0x0b, 0x57, 0xef, 0xda, 0xbd, 0x0d, 0xcb, 0xf9, 0x8d, 0x5c, 0x7e, 0x05, 0x00, 0x00, 0xff,
|
||||
0xff, 0x26, 0x11, 0xba, 0xff, 0x89, 0x02, 0x00, 0x00,
|
||||
}
|
||||
Reference in New Issue
Block a user