Do not panic of redis is not configured (#3981)

This commit is contained in:
Benjamin Pracht
2025-10-06 07:47:29 -07:00
committed by GitHub
parent 01337ba730
commit 146bd9699d
2 changed files with 28 additions and 0 deletions
+16
View File
@@ -86,6 +86,10 @@ func (s *IOInfoService) Stop() {
}
func (s *IOInfoService) CreateEgress(ctx context.Context, info *livekit.EgressInfo) (*emptypb.Empty, error) {
if s.es == nil {
return nil, ErrEgressNotConnected
}
// check if egress already exists to avoid duplicate EgressStarted event
if _, err := s.es.LoadEgress(ctx, info.EgressId); err == nil {
return &emptypb.Empty{}, nil
@@ -103,6 +107,10 @@ func (s *IOInfoService) CreateEgress(ctx context.Context, info *livekit.EgressIn
}
func (s *IOInfoService) UpdateEgress(ctx context.Context, info *livekit.EgressInfo) (*emptypb.Empty, error) {
if s.es == nil {
return nil, ErrEgressNotConnected
}
err := s.es.UpdateEgress(ctx, info)
switch info.Status {
@@ -126,6 +134,10 @@ func (s *IOInfoService) UpdateEgress(ctx context.Context, info *livekit.EgressIn
}
func (s *IOInfoService) GetEgress(ctx context.Context, req *rpc.GetEgressRequest) (*livekit.EgressInfo, error) {
if s.es == nil {
return nil, ErrEgressNotConnected
}
info, err := s.es.LoadEgress(ctx, req.EgressId)
if err != nil {
logger.Errorw("failed to load egress", err)
@@ -136,6 +148,10 @@ func (s *IOInfoService) GetEgress(ctx context.Context, req *rpc.GetEgressRequest
}
func (s *IOInfoService) ListEgress(ctx context.Context, req *livekit.ListEgressRequest) (*livekit.ListEgressResponse, error) {
if s.es == nil {
return nil, ErrEgressNotConnected
}
if req.EgressId != "" {
info, err := s.es.LoadEgress(ctx, req.EgressId)
if err != nil {
+12
View File
@@ -25,6 +25,10 @@ import (
)
func (s *IOInfoService) CreateIngress(ctx context.Context, info *livekit.IngressInfo) (*emptypb.Empty, error) {
if s.is == nil {
return nil, ErrIngressNotConnected
}
err := s.is.StoreIngress(ctx, info)
if err != nil {
return nil, err
@@ -45,6 +49,10 @@ func (s *IOInfoService) GetIngressInfo(ctx context.Context, req *rpc.GetIngressI
}
func (s *IOInfoService) loadIngressFromInfoRequest(req *rpc.GetIngressInfoRequest) (info *livekit.IngressInfo, err error) {
if s.is == nil {
return nil, ErrIngressNotConnected
}
if req.IngressId != "" {
info, err = s.is.LoadIngress(context.Background(), req.IngressId)
} else if req.StreamKey != "" {
@@ -56,6 +64,10 @@ func (s *IOInfoService) loadIngressFromInfoRequest(req *rpc.GetIngressInfoReques
}
func (s *IOInfoService) UpdateIngressState(ctx context.Context, req *rpc.UpdateIngressStateRequest) (*emptypb.Empty, error) {
if s.is == nil {
return nil, ErrIngressNotConnected
}
info, err := s.is.LoadIngress(ctx, req.IngressId)
if err != nil {
return nil, err