Remove deprecated ingress rpc (#1439)
* remove legacy ingress rpcs * remove from io service
This commit is contained in:
@@ -244,7 +244,6 @@ type EgressConfig struct {
|
|||||||
|
|
||||||
type IngressConfig struct {
|
type IngressConfig struct {
|
||||||
RTMPBaseURL string `yaml:"rtmp_base_url"`
|
RTMPBaseURL string `yaml:"rtmp_base_url"`
|
||||||
UsePsRPC bool `yaml:"use_psrpc"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// not exposed to YAML
|
// not exposed to YAML
|
||||||
|
|||||||
+5
-78
@@ -2,11 +2,9 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/config"
|
"github.com/livekit/livekit-server/pkg/config"
|
||||||
"github.com/livekit/livekit-server/pkg/telemetry"
|
"github.com/livekit/livekit-server/pkg/telemetry"
|
||||||
"github.com/livekit/protocol/ingress"
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
"github.com/livekit/protocol/rpc"
|
"github.com/livekit/protocol/rpc"
|
||||||
@@ -14,17 +12,11 @@ import (
|
|||||||
"github.com/livekit/psrpc"
|
"github.com/livekit/psrpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
initialTimeout = time.Second * 3
|
|
||||||
retryTimeout = time.Minute * 1
|
|
||||||
)
|
|
||||||
|
|
||||||
type IngressService struct {
|
type IngressService struct {
|
||||||
conf *config.IngressConfig
|
conf *config.IngressConfig
|
||||||
nodeID livekit.NodeID
|
nodeID livekit.NodeID
|
||||||
bus psrpc.MessageBus
|
bus psrpc.MessageBus
|
||||||
psrpcClient rpc.IngressClient
|
psrpcClient rpc.IngressClient
|
||||||
rpcClient ingress.RPCClient
|
|
||||||
store IngressStore
|
store IngressStore
|
||||||
roomService livekit.RoomService
|
roomService livekit.RoomService
|
||||||
telemetry telemetry.TelemetryService
|
telemetry telemetry.TelemetryService
|
||||||
@@ -35,7 +27,6 @@ func NewIngressService(
|
|||||||
nodeID livekit.NodeID,
|
nodeID livekit.NodeID,
|
||||||
bus psrpc.MessageBus,
|
bus psrpc.MessageBus,
|
||||||
psrpcClient rpc.IngressClient,
|
psrpcClient rpc.IngressClient,
|
||||||
rpcClient ingress.RPCClient,
|
|
||||||
store IngressStore,
|
store IngressStore,
|
||||||
rs livekit.RoomService,
|
rs livekit.RoomService,
|
||||||
ts telemetry.TelemetryService,
|
ts telemetry.TelemetryService,
|
||||||
@@ -46,7 +37,6 @@ func NewIngressService(
|
|||||||
nodeID: nodeID,
|
nodeID: nodeID,
|
||||||
bus: bus,
|
bus: bus,
|
||||||
psrpcClient: psrpcClient,
|
psrpcClient: psrpcClient,
|
||||||
rpcClient: rpcClient,
|
|
||||||
store: store,
|
store: store,
|
||||||
roomService: rs,
|
roomService: rs,
|
||||||
telemetry: ts,
|
telemetry: ts,
|
||||||
@@ -100,7 +90,7 @@ func (s *IngressService) CreateIngressWithUrlPrefix(ctx context.Context, urlPref
|
|||||||
State: &livekit.IngressState{},
|
State: &livekit.IngressState{},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.store.StoreIngress(ctx, info); err != nil {
|
if err = s.store.StoreIngress(ctx, info); err != nil {
|
||||||
logger.Errorw("could not write ingress info", err)
|
logger.Errorw("could not write ingress info", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -108,41 +98,6 @@ func (s *IngressService) CreateIngressWithUrlPrefix(ctx context.Context, urlPref
|
|||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *IngressService) sendRPCWithRetry(ctx context.Context, req *livekit.IngressRequest) (*livekit.IngressState, error) {
|
|
||||||
type result struct {
|
|
||||||
state *livekit.IngressState
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
resChan := make(chan result, 1)
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
cctx, _ := context.WithTimeout(context.Background(), retryTimeout)
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-cctx.Done():
|
|
||||||
resChan <- result{nil, ingress.ErrNoResponse}
|
|
||||||
return
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
s, err := s.rpcClient.SendRequest(cctx, req)
|
|
||||||
if err != ingress.ErrNoResponse {
|
|
||||||
resChan <- result{s, err}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
select {
|
|
||||||
case res := <-resChan:
|
|
||||||
return res.state, res.err
|
|
||||||
case <-time.After(initialTimeout):
|
|
||||||
return nil, ingress.ErrNoResponse
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *IngressService) UpdateIngress(ctx context.Context, req *livekit.UpdateIngressRequest) (*livekit.IngressInfo, error) {
|
func (s *IngressService) UpdateIngress(ctx context.Context, req *livekit.UpdateIngressRequest) (*livekit.IngressInfo, error) {
|
||||||
fields := []interface{}{
|
fields := []interface{}{
|
||||||
"ingress", req.IngressId,
|
"ingress", req.IngressId,
|
||||||
@@ -157,7 +112,7 @@ func (s *IngressService) UpdateIngress(ctx context.Context, req *livekit.UpdateI
|
|||||||
return nil, twirpAuthError(err)
|
return nil, twirpAuthError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.psrpcClient == nil && s.rpcClient == nil {
|
if s.psrpcClient == nil {
|
||||||
return nil, ErrIngressNotConnected
|
return nil, ErrIngressNotConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,21 +154,7 @@ func (s *IngressService) UpdateIngress(ctx context.Context, req *livekit.UpdateI
|
|||||||
case livekit.IngressState_ENDPOINT_BUFFERING,
|
case livekit.IngressState_ENDPOINT_BUFFERING,
|
||||||
livekit.IngressState_ENDPOINT_PUBLISHING:
|
livekit.IngressState_ENDPOINT_PUBLISHING:
|
||||||
// Do not update store the returned state as the ingress service will do it
|
// Do not update store the returned state as the ingress service will do it
|
||||||
race := rpc.NewRace[livekit.IngressState](ctx)
|
if _, err = s.psrpcClient.UpdateIngress(ctx, req.IngressId, req); err != nil {
|
||||||
if s.rpcClient != nil {
|
|
||||||
race.Go(func(ctx context.Context) (*livekit.IngressState, error) {
|
|
||||||
return s.sendRPCWithRetry(ctx, &livekit.IngressRequest{
|
|
||||||
IngressId: req.IngressId,
|
|
||||||
Request: &livekit.IngressRequest_Update{Update: req},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if s.psrpcClient != nil {
|
|
||||||
race.Go(func(ctx context.Context) (*livekit.IngressState, error) {
|
|
||||||
return s.psrpcClient.UpdateIngress(ctx, req.IngressId, req)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if _, _, err := race.Wait(); err != nil {
|
|
||||||
logger.Warnw("could not update active ingress", err)
|
logger.Warnw("could not update active ingress", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,7 +193,7 @@ func (s *IngressService) DeleteIngress(ctx context.Context, req *livekit.DeleteI
|
|||||||
return nil, twirpAuthError(err)
|
return nil, twirpAuthError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.psrpcClient == nil && s.rpcClient == nil {
|
if s.psrpcClient == nil {
|
||||||
return nil, ErrIngressNotConnected
|
return nil, ErrIngressNotConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,21 +205,7 @@ func (s *IngressService) DeleteIngress(ctx context.Context, req *livekit.DeleteI
|
|||||||
switch info.State.Status {
|
switch info.State.Status {
|
||||||
case livekit.IngressState_ENDPOINT_BUFFERING,
|
case livekit.IngressState_ENDPOINT_BUFFERING,
|
||||||
livekit.IngressState_ENDPOINT_PUBLISHING:
|
livekit.IngressState_ENDPOINT_PUBLISHING:
|
||||||
race := rpc.NewRace[livekit.IngressState](ctx)
|
if _, err = s.psrpcClient.DeleteIngress(ctx, req.IngressId, req); err != nil {
|
||||||
if s.rpcClient != nil {
|
|
||||||
race.Go(func(ctx context.Context) (*livekit.IngressState, error) {
|
|
||||||
return s.sendRPCWithRetry(ctx, &livekit.IngressRequest{
|
|
||||||
IngressId: req.IngressId,
|
|
||||||
Request: &livekit.IngressRequest_Delete{Delete: req},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if s.psrpcClient != nil {
|
|
||||||
race.Go(func(ctx context.Context) (*livekit.IngressState, error) {
|
|
||||||
return s.psrpcClient.DeleteIngress(ctx, req.IngressId, req)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if _, _, err := race.Wait(); err != nil {
|
|
||||||
logger.Warnw("could not stop active ingress", err)
|
logger.Warnw("could not stop active ingress", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/telemetry"
|
"github.com/livekit/livekit-server/pkg/telemetry"
|
||||||
"github.com/livekit/protocol/egress"
|
"github.com/livekit/protocol/egress"
|
||||||
"github.com/livekit/protocol/ingress"
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
"github.com/livekit/protocol/rpc"
|
"github.com/livekit/protocol/rpc"
|
||||||
@@ -23,7 +22,6 @@ type IOInfoService struct {
|
|||||||
is IngressStore
|
is IngressStore
|
||||||
telemetry telemetry.TelemetryService
|
telemetry telemetry.TelemetryService
|
||||||
ecDeprecated egress.RPCClient
|
ecDeprecated egress.RPCClient
|
||||||
icDeprecated ingress.RPCClient
|
|
||||||
shutdown chan struct{}
|
shutdown chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,14 +32,12 @@ func NewIOInfoService(
|
|||||||
is IngressStore,
|
is IngressStore,
|
||||||
ts telemetry.TelemetryService,
|
ts telemetry.TelemetryService,
|
||||||
ec egress.RPCClient,
|
ec egress.RPCClient,
|
||||||
ic ingress.RPCClient,
|
|
||||||
) (*IOInfoService, error) {
|
) (*IOInfoService, error) {
|
||||||
s := &IOInfoService{
|
s := &IOInfoService{
|
||||||
es: es,
|
es: es,
|
||||||
is: is,
|
is: is,
|
||||||
telemetry: ts,
|
telemetry: ts,
|
||||||
ecDeprecated: ec,
|
ecDeprecated: ec,
|
||||||
icDeprecated: ic,
|
|
||||||
shutdown: make(chan struct{}),
|
shutdown: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +62,6 @@ func (s *IOInfoService) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go s.egressWorkerDeprecated()
|
go s.egressWorkerDeprecated()
|
||||||
go s.ingressWorkerDeprecated()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -180,72 +175,3 @@ func (s *IOInfoService) egressWorkerDeprecated() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated
|
|
||||||
func (s *IOInfoService) ingressWorkerDeprecated() {
|
|
||||||
if s.icDeprecated == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
updates, err := s.icDeprecated.GetUpdateChannel(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
logger.Errorw("failed to subscribe to results channel", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
entities, err := s.icDeprecated.GetEntityChannel(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
logger.Errorw("failed to subscribe to entities channel", err)
|
|
||||||
_ = updates.Close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
updateChan := updates.Channel()
|
|
||||||
entityChan := entities.Channel()
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case msg := <-updateChan:
|
|
||||||
b := updates.Payload(msg)
|
|
||||||
|
|
||||||
res := &livekit.UpdateIngressStateRequest{}
|
|
||||||
if err = proto.Unmarshal(b, res); err != nil {
|
|
||||||
logger.Errorw("failed to read results", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// save updated info to store
|
|
||||||
err = s.is.UpdateIngressState(context.Background(), res.IngressId, res.State)
|
|
||||||
if err != nil {
|
|
||||||
logger.Errorw("could not update ingress", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
case msg := <-entityChan:
|
|
||||||
b := entities.Payload(msg)
|
|
||||||
|
|
||||||
req := &livekit.GetIngressInfoRequest{}
|
|
||||||
if err = proto.Unmarshal(b, req); err != nil {
|
|
||||||
logger.Errorw("failed to read request", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
info, err := s.loadIngressFromInfoRequest(&rpc.GetIngressInfoRequest{
|
|
||||||
IngressId: req.IngressId,
|
|
||||||
StreamKey: req.StreamKey,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
logger.Errorw("failed to load ingress info", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
err = s.icDeprecated.SendGetIngressInfoResponse(context.Background(), req, &livekit.GetIngressInfoResponse{Info: info}, err)
|
|
||||||
if err != nil {
|
|
||||||
logger.Errorw("could not send response", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
case <-s.shutdown:
|
|
||||||
_ = updates.Close()
|
|
||||||
_ = entities.Close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-16
@@ -20,7 +20,6 @@ import (
|
|||||||
"github.com/livekit/livekit-server/pkg/utils"
|
"github.com/livekit/livekit-server/pkg/utils"
|
||||||
"github.com/livekit/protocol/auth"
|
"github.com/livekit/protocol/auth"
|
||||||
"github.com/livekit/protocol/egress"
|
"github.com/livekit/protocol/egress"
|
||||||
"github.com/livekit/protocol/ingress"
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
redisLiveKit "github.com/livekit/protocol/redis"
|
redisLiveKit "github.com/livekit/protocol/redis"
|
||||||
"github.com/livekit/protocol/rpc"
|
"github.com/livekit/protocol/rpc"
|
||||||
@@ -51,11 +50,9 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
|||||||
getEgressStore,
|
getEgressStore,
|
||||||
NewEgressLauncher,
|
NewEgressLauncher,
|
||||||
NewEgressService,
|
NewEgressService,
|
||||||
ingress.NewRedisRPC,
|
rpc.NewIngressClient,
|
||||||
getIngressClient,
|
|
||||||
getIngressStore,
|
getIngressStore,
|
||||||
getIngressConfig,
|
getIngressConfig,
|
||||||
getIngressRPCClient,
|
|
||||||
NewIngressService,
|
NewIngressService,
|
||||||
NewRoomAllocator,
|
NewRoomAllocator,
|
||||||
NewRoomService,
|
NewRoomService,
|
||||||
@@ -161,14 +158,6 @@ func getEgressStore(s ObjectStore) EgressStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIngressClient(conf *config.Config, nodeID livekit.NodeID, bus psrpc.MessageBus) (rpc.IngressClient, error) {
|
|
||||||
if conf.Ingress.UsePsRPC {
|
|
||||||
return rpc.NewIngressClient(nodeID, bus)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getIngressStore(s ObjectStore) IngressStore {
|
func getIngressStore(s ObjectStore) IngressStore {
|
||||||
switch store := s.(type) {
|
switch store := s.(type) {
|
||||||
case *RedisStore:
|
case *RedisStore:
|
||||||
@@ -182,10 +171,6 @@ func getIngressConfig(conf *config.Config) *config.IngressConfig {
|
|||||||
return &conf.Ingress
|
return &conf.Ingress
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIngressRPCClient(rpc ingress.RPC) ingress.RPCClient {
|
|
||||||
return rpc
|
|
||||||
}
|
|
||||||
|
|
||||||
func createClientConfiguration() clientconfiguration.ClientConfigurationManager {
|
func createClientConfiguration() clientconfiguration.ClientConfigurationManager {
|
||||||
return clientconfiguration.NewStaticClientConfigurationManager(clientconfiguration.StaticConfigurations)
|
return clientconfiguration.NewStaticClientConfigurationManager(clientconfiguration.StaticConfigurations)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-18
@@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/livekit/livekit-server/pkg/utils"
|
"github.com/livekit/livekit-server/pkg/utils"
|
||||||
"github.com/livekit/protocol/auth"
|
"github.com/livekit/protocol/auth"
|
||||||
"github.com/livekit/protocol/egress"
|
"github.com/livekit/protocol/egress"
|
||||||
"github.com/livekit/protocol/ingress"
|
|
||||||
"github.com/livekit/protocol/livekit"
|
"github.com/livekit/protocol/livekit"
|
||||||
redis2 "github.com/livekit/protocol/redis"
|
redis2 "github.com/livekit/protocol/redis"
|
||||||
"github.com/livekit/protocol/rpc"
|
"github.com/livekit/protocol/rpc"
|
||||||
@@ -72,15 +71,13 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
|||||||
}
|
}
|
||||||
egressService := NewEgressService(egressClient, rpcClient, objectStore, egressStore, roomService, telemetryService, rtcEgressLauncher)
|
egressService := NewEgressService(egressClient, rpcClient, objectStore, egressStore, roomService, telemetryService, rtcEgressLauncher)
|
||||||
ingressConfig := getIngressConfig(conf)
|
ingressConfig := getIngressConfig(conf)
|
||||||
ingressClient, err := getIngressClient(conf, nodeID, messageBus)
|
ingressClient, err := rpc.NewIngressClient(nodeID, messageBus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rpc := ingress.NewRedisRPC(nodeID, universalClient)
|
|
||||||
ingressRPCClient := getIngressRPCClient(rpc)
|
|
||||||
ingressStore := getIngressStore(objectStore)
|
ingressStore := getIngressStore(objectStore)
|
||||||
ingressService := NewIngressService(ingressConfig, nodeID, messageBus, ingressClient, ingressRPCClient, ingressStore, roomService, telemetryService)
|
ingressService := NewIngressService(ingressConfig, nodeID, messageBus, ingressClient, ingressStore, roomService, telemetryService)
|
||||||
ioInfoService, err := NewIOInfoService(nodeID, messageBus, egressStore, ingressStore, telemetryService, rpcClient, ingressRPCClient)
|
ioInfoService, err := NewIOInfoService(nodeID, messageBus, egressStore, ingressStore, telemetryService, rpcClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -197,14 +194,6 @@ func getEgressStore(s ObjectStore) EgressStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIngressClient(conf *config.Config, nodeID livekit.NodeID, bus psrpc.MessageBus) (rpc.IngressClient, error) {
|
|
||||||
if conf.Ingress.UsePsRPC {
|
|
||||||
return rpc.NewIngressClient(nodeID, bus)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getIngressStore(s ObjectStore) IngressStore {
|
func getIngressStore(s ObjectStore) IngressStore {
|
||||||
switch store := s.(type) {
|
switch store := s.(type) {
|
||||||
case *RedisStore:
|
case *RedisStore:
|
||||||
@@ -218,10 +207,6 @@ func getIngressConfig(conf *config.Config) *config.IngressConfig {
|
|||||||
return &conf.Ingress
|
return &conf.Ingress
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIngressRPCClient(rpc2 ingress.RPC) ingress.RPCClient {
|
|
||||||
return rpc2
|
|
||||||
}
|
|
||||||
|
|
||||||
func createClientConfiguration() clientconfiguration.ClientConfigurationManager {
|
func createClientConfiguration() clientconfiguration.ClientConfigurationManager {
|
||||||
return clientconfiguration.NewStaticClientConfigurationManager(clientconfiguration.StaticConfigurations)
|
return clientconfiguration.NewStaticClientConfigurationManager(clientconfiguration.StaticConfigurations)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user