Auto egress (#1011)
* auto egress * fix room service test * reuse StartTrackEgress * add timestamp * update prefixed filename explicitly * update protocol * clean up telemetry * fix telemetry tests * separate room internal storage * auto participant egress * remove custom template url * fix internal key * use map for stats workers * remove sync.Map * remove participant composite
This commit is contained in:
+27
-3
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/rtc"
|
||||
"github.com/livekit/protocol/egress"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/logger"
|
||||
@@ -21,23 +22,43 @@ type EgressService struct {
|
||||
es EgressStore
|
||||
roomService livekit.RoomService
|
||||
telemetry telemetry.TelemetryService
|
||||
launcher rtc.EgressLauncher
|
||||
shutdown chan struct{}
|
||||
}
|
||||
|
||||
type egressLauncher struct {
|
||||
rpcClient egress.RPCClient
|
||||
es EgressStore
|
||||
telemetry telemetry.TelemetryService
|
||||
}
|
||||
|
||||
func NewEgressLauncher(rpcClient egress.RPCClient, es EgressStore, ts telemetry.TelemetryService) rtc.EgressLauncher {
|
||||
if rpcClient == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &egressLauncher{
|
||||
rpcClient: rpcClient,
|
||||
es: es,
|
||||
telemetry: ts,
|
||||
}
|
||||
}
|
||||
|
||||
func NewEgressService(
|
||||
rpcClient egress.RPCClient,
|
||||
store ServiceStore,
|
||||
es EgressStore,
|
||||
rs livekit.RoomService,
|
||||
ts telemetry.TelemetryService,
|
||||
launcher rtc.EgressLauncher,
|
||||
) *EgressService {
|
||||
|
||||
return &EgressService{
|
||||
rpcClient: rpcClient,
|
||||
store: store,
|
||||
es: es,
|
||||
roomService: rs,
|
||||
telemetry: ts,
|
||||
launcher: launcher,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +106,7 @@ func (s *EgressService) StartTrackEgress(ctx context.Context, req *livekit.Track
|
||||
func (s *EgressService) StartEgress(ctx context.Context, roomName livekit.RoomName, req *livekit.StartEgressRequest) (*livekit.EgressInfo, error) {
|
||||
if err := EnsureRecordPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
}
|
||||
if s.rpcClient == nil {
|
||||
} else if s.launcher == nil {
|
||||
return nil, ErrEgressNotConnected
|
||||
}
|
||||
|
||||
@@ -96,6 +116,10 @@ func (s *EgressService) StartEgress(ctx context.Context, roomName livekit.RoomNa
|
||||
}
|
||||
req.RoomId = room.Sid
|
||||
|
||||
return s.launcher.StartEgress(ctx, req)
|
||||
}
|
||||
|
||||
func (s *egressLauncher) StartEgress(ctx context.Context, req *livekit.StartEgressRequest) (*livekit.EgressInfo, error) {
|
||||
info, err := s.rpcClient.SendRequest(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -10,17 +10,19 @@ import (
|
||||
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
|
||||
|
||||
// encapsulates CRUD operations for room settings
|
||||
//
|
||||
//counterfeiter:generate . ObjectStore
|
||||
type ObjectStore interface {
|
||||
ServiceStore
|
||||
|
||||
// enable locking on a specific room to prevent race
|
||||
// returns a (lock uuid, error)
|
||||
LockRoom(ctx context.Context, name livekit.RoomName, duration time.Duration) (string, error)
|
||||
UnlockRoom(ctx context.Context, name livekit.RoomName, uid string) error
|
||||
LockRoom(ctx context.Context, roomName livekit.RoomName, duration time.Duration) (string, error)
|
||||
UnlockRoom(ctx context.Context, roomName livekit.RoomName, uid string) error
|
||||
|
||||
StoreRoom(ctx context.Context, room *livekit.Room) error
|
||||
DeleteRoom(ctx context.Context, name livekit.RoomName) error
|
||||
StoreRoomInternal(ctx context.Context, roomName livekit.RoomName, internal *livekit.RoomInternal) error
|
||||
DeleteRoom(ctx context.Context, roomName livekit.RoomName) error
|
||||
|
||||
StoreParticipant(ctx context.Context, roomName livekit.RoomName, participant *livekit.ParticipantInfo) error
|
||||
DeleteParticipant(ctx context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error
|
||||
@@ -28,11 +30,12 @@ type ObjectStore interface {
|
||||
|
||||
//counterfeiter:generate . ServiceStore
|
||||
type ServiceStore interface {
|
||||
LoadRoom(ctx context.Context, name livekit.RoomName) (*livekit.Room, error)
|
||||
LoadRoom(ctx context.Context, roomName livekit.RoomName) (*livekit.Room, error)
|
||||
LoadRoomInternal(ctx context.Context, roomName livekit.RoomName) (*livekit.RoomInternal, error)
|
||||
|
||||
// ListRooms returns currently active rooms. if names is not nil, it'll filter and return
|
||||
// only rooms that match
|
||||
ListRooms(ctx context.Context, names []livekit.RoomName) ([]*livekit.Room, error)
|
||||
|
||||
ListRooms(ctx context.Context, roomNames []livekit.RoomName) ([]*livekit.Room, error)
|
||||
LoadParticipant(ctx context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error)
|
||||
ListParticipants(ctx context.Context, roomName livekit.RoomName) ([]*livekit.ParticipantInfo, error)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ import (
|
||||
// encapsulates CRUD operations for room settings
|
||||
type LocalStore struct {
|
||||
// map of roomName => room
|
||||
rooms map[livekit.RoomName]*livekit.Room
|
||||
rooms map[livekit.RoomName]*livekit.Room
|
||||
roomInternal map[livekit.RoomName]*livekit.RoomInternal
|
||||
// map of roomName => { identity: participant }
|
||||
participants map[livekit.RoomName]map[livekit.ParticipantIdentity]*livekit.ParticipantInfo
|
||||
|
||||
@@ -39,31 +40,45 @@ func (s *LocalStore) StoreRoom(_ context.Context, room *livekit.Room) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *LocalStore) LoadRoom(_ context.Context, name livekit.RoomName) (*livekit.Room, error) {
|
||||
func (s *LocalStore) StoreRoomInternal(_ context.Context, roomName livekit.RoomName, internal *livekit.RoomInternal) error {
|
||||
s.lock.Lock()
|
||||
s.roomInternal[roomName] = internal
|
||||
s.lock.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *LocalStore) LoadRoom(_ context.Context, roomName livekit.RoomName) (*livekit.Room, error) {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
|
||||
room := s.rooms[name]
|
||||
room := s.rooms[roomName]
|
||||
if room == nil {
|
||||
return nil, ErrRoomNotFound
|
||||
}
|
||||
return room, nil
|
||||
}
|
||||
|
||||
func (s *LocalStore) ListRooms(_ context.Context, names []livekit.RoomName) ([]*livekit.Room, error) {
|
||||
func (s *LocalStore) LoadRoomInternal(_ context.Context, roomName livekit.RoomName) (*livekit.RoomInternal, error) {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
|
||||
return s.roomInternal[roomName], nil
|
||||
}
|
||||
|
||||
func (s *LocalStore) ListRooms(_ context.Context, roomNames []livekit.RoomName) ([]*livekit.Room, error) {
|
||||
s.lock.RLock()
|
||||
defer s.lock.RUnlock()
|
||||
rooms := make([]*livekit.Room, 0, len(s.rooms))
|
||||
for _, r := range s.rooms {
|
||||
if names == nil || funk.Contains(names, livekit.RoomName(r.Name)) {
|
||||
if roomNames == nil || funk.Contains(roomNames, livekit.RoomName(r.Name)) {
|
||||
rooms = append(rooms, r)
|
||||
}
|
||||
}
|
||||
return rooms, nil
|
||||
}
|
||||
|
||||
func (s *LocalStore) DeleteRoom(ctx context.Context, name livekit.RoomName) error {
|
||||
room, err := s.LoadRoom(ctx, name)
|
||||
func (s *LocalStore) DeleteRoom(ctx context.Context, roomName livekit.RoomName) error {
|
||||
room, err := s.LoadRoom(ctx, roomName)
|
||||
if err == ErrRoomNotFound {
|
||||
return nil
|
||||
} else if err != nil {
|
||||
|
||||
+50
-15
@@ -23,7 +23,8 @@ const (
|
||||
VersionKey = "livekit_version"
|
||||
|
||||
// RoomsKey is hash of room_name => Room proto
|
||||
RoomsKey = "rooms"
|
||||
RoomsKey = "rooms"
|
||||
RoomInternalKey = "room_internal"
|
||||
|
||||
// EgressKey is a hash of egressID => egress info
|
||||
EgressKey = "egress"
|
||||
@@ -115,8 +116,23 @@ func (s *RedisStore) StoreRoom(_ context.Context, room *livekit.Room) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) LoadRoom(_ context.Context, name livekit.RoomName) (*livekit.Room, error) {
|
||||
data, err := s.rc.HGet(s.ctx, RoomsKey, string(name)).Result()
|
||||
func (s *RedisStore) StoreRoomInternal(_ context.Context, roomName livekit.RoomName, internal *livekit.RoomInternal) error {
|
||||
data, err := proto.Marshal(internal)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pp := s.rc.Pipeline()
|
||||
pp.HSet(s.ctx, RoomInternalKey, roomName, data)
|
||||
|
||||
if _, err = pp.Exec(s.ctx); err != nil {
|
||||
return errors.Wrap(err, "could not create room")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) LoadRoom(_ context.Context, roomName livekit.RoomName) (*livekit.Room, error) {
|
||||
data, err := s.rc.HGet(s.ctx, RoomsKey, string(roomName)).Result()
|
||||
if err != nil {
|
||||
if err == redis.Nil {
|
||||
err = ErrRoomNotFound
|
||||
@@ -133,18 +149,36 @@ func (s *RedisStore) LoadRoom(_ context.Context, name livekit.RoomName) (*liveki
|
||||
return &room, nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) ListRooms(_ context.Context, names []livekit.RoomName) ([]*livekit.Room, error) {
|
||||
func (s *RedisStore) LoadRoomInternal(_ context.Context, roomName livekit.RoomName) (*livekit.RoomInternal, error) {
|
||||
data, err := s.rc.HGet(s.ctx, RoomInternalKey, string(roomName)).Result()
|
||||
if err != nil {
|
||||
if err == redis.Nil {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
internal := &livekit.RoomInternal{}
|
||||
err = proto.Unmarshal([]byte(data), internal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return internal, nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) ListRooms(_ context.Context, roomNames []livekit.RoomName) ([]*livekit.Room, error) {
|
||||
var items []string
|
||||
var err error
|
||||
if names == nil {
|
||||
if roomNames == nil {
|
||||
items, err = s.rc.HVals(s.ctx, RoomsKey).Result()
|
||||
if err != nil && err != redis.Nil {
|
||||
return nil, errors.Wrap(err, "could not get rooms")
|
||||
}
|
||||
} else {
|
||||
roomNames := livekit.RoomNamesAsStrings(names)
|
||||
names := livekit.RoomNamesAsStrings(roomNames)
|
||||
var results []interface{}
|
||||
results, err = s.rc.HMGet(s.ctx, RoomsKey, roomNames...).Result()
|
||||
results, err = s.rc.HMGet(s.ctx, RoomsKey, names...).Result()
|
||||
if err != nil && err != redis.Nil {
|
||||
return nil, errors.Wrap(err, "could not get rooms by names")
|
||||
}
|
||||
@@ -168,23 +202,24 @@ func (s *RedisStore) ListRooms(_ context.Context, names []livekit.RoomName) ([]*
|
||||
return rooms, nil
|
||||
}
|
||||
|
||||
func (s *RedisStore) DeleteRoom(ctx context.Context, name livekit.RoomName) error {
|
||||
_, err := s.LoadRoom(ctx, name)
|
||||
func (s *RedisStore) DeleteRoom(ctx context.Context, roomName livekit.RoomName) error {
|
||||
_, err := s.LoadRoom(ctx, roomName)
|
||||
if err == ErrRoomNotFound {
|
||||
return nil
|
||||
}
|
||||
|
||||
pp := s.rc.Pipeline()
|
||||
pp.HDel(s.ctx, RoomsKey, string(name))
|
||||
pp.Del(s.ctx, RoomParticipantsPrefix+string(name))
|
||||
pp.HDel(s.ctx, RoomsKey, string(roomName))
|
||||
pp.HDel(s.ctx, RoomInternalKey, string(roomName))
|
||||
pp.Del(s.ctx, RoomParticipantsPrefix+string(roomName))
|
||||
|
||||
_, err = pp.Exec(s.ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *RedisStore) LockRoom(_ context.Context, name livekit.RoomName, duration time.Duration) (string, error) {
|
||||
func (s *RedisStore) LockRoom(_ context.Context, roomName livekit.RoomName, duration time.Duration) (string, error) {
|
||||
token := utils.NewGuid("LOCK")
|
||||
key := RoomLockPrefix + string(name)
|
||||
key := RoomLockPrefix + string(roomName)
|
||||
|
||||
startTime := time.Now()
|
||||
for {
|
||||
@@ -207,8 +242,8 @@ func (s *RedisStore) LockRoom(_ context.Context, name livekit.RoomName, duration
|
||||
return "", ErrRoomLockFailed
|
||||
}
|
||||
|
||||
func (s *RedisStore) UnlockRoom(_ context.Context, name livekit.RoomName, uid string) error {
|
||||
key := RoomLockPrefix + string(name)
|
||||
func (s *RedisStore) UnlockRoom(_ context.Context, roomName livekit.RoomName, uid string) error {
|
||||
key := RoomLockPrefix + string(roomName)
|
||||
|
||||
val, err := s.rc.Get(s.ctx, key).Result()
|
||||
if err == redis.Nil {
|
||||
|
||||
@@ -68,10 +68,18 @@ func (r *StandardRoomAllocator) CreateRoom(ctx context.Context, req *livekit.Cre
|
||||
if req.Metadata != "" {
|
||||
rm.Metadata = req.Metadata
|
||||
}
|
||||
if err := r.roomStore.StoreRoom(ctx, rm); err != nil {
|
||||
|
||||
if err = r.roomStore.StoreRoom(ctx, rm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if req.Egress != nil && req.Egress.Tracks != nil {
|
||||
internal := &livekit.RoomInternal{TrackEgress: req.Egress.Tracks}
|
||||
if err = r.roomStore.StoreRoomInternal(ctx, livekit.RoomName(req.Name), internal); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// check if room already assigned
|
||||
existing, err := r.router.GetNodeForRoom(ctx, livekit.RoomName(rm.Name))
|
||||
if err != routing.ErrNotFound && err != nil {
|
||||
|
||||
@@ -48,6 +48,7 @@ type RoomManager struct {
|
||||
roomStore ObjectStore
|
||||
telemetry telemetry.TelemetryService
|
||||
clientConfManager clientconfiguration.ClientConfigurationManager
|
||||
egressLauncher rtc.EgressLauncher
|
||||
|
||||
rooms map[livekit.RoomName]*rtc.Room
|
||||
|
||||
@@ -61,6 +62,7 @@ func NewLocalRoomManager(
|
||||
router routing.Router,
|
||||
telemetry telemetry.TelemetryService,
|
||||
clientConfManager clientconfiguration.ClientConfigurationManager,
|
||||
egressLauncher rtc.EgressLauncher,
|
||||
) (*RoomManager, error) {
|
||||
|
||||
rtcConf, err := rtc.NewWebRTCConfig(conf, currentNode.Ip)
|
||||
@@ -76,6 +78,7 @@ func NewLocalRoomManager(
|
||||
roomStore: roomStore,
|
||||
telemetry: telemetry,
|
||||
clientConfManager: clientConfManager,
|
||||
egressLauncher: egressLauncher,
|
||||
|
||||
rooms: make(map[livekit.RoomName]*rtc.Room),
|
||||
|
||||
@@ -373,6 +376,11 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room
|
||||
return nil, err
|
||||
}
|
||||
|
||||
internal, err := r.roomStore.LoadRoomInternal(ctx, roomName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r.lock.Lock()
|
||||
|
||||
currentRoom := r.rooms[roomName]
|
||||
@@ -388,7 +396,7 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room
|
||||
}
|
||||
|
||||
// construct ice servers
|
||||
newRoom := rtc.NewRoom(ri, *r.rtcConfig, &r.config.Audio, r.serverInfo, r.telemetry)
|
||||
newRoom := rtc.NewRoom(ri, internal, *r.rtcConfig, &r.config.Audio, r.serverInfo, r.telemetry, r.egressLauncher)
|
||||
|
||||
newRoom.OnClose(func() {
|
||||
roomInfo := newRoom.ToProto()
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/livekit/livekit-server/pkg/config"
|
||||
"github.com/livekit/livekit-server/pkg/routing"
|
||||
"github.com/livekit/livekit-server/pkg/rtc"
|
||||
"github.com/livekit/protocol/livekit"
|
||||
)
|
||||
|
||||
@@ -22,18 +23,27 @@ const (
|
||||
|
||||
// A rooms service that supports a single node
|
||||
type RoomService struct {
|
||||
router routing.MessageRouter
|
||||
roomAllocator RoomAllocator
|
||||
roomStore ServiceStore
|
||||
conf config.RoomConfig
|
||||
conf config.RoomConfig
|
||||
router routing.MessageRouter
|
||||
roomAllocator RoomAllocator
|
||||
roomStore ServiceStore
|
||||
egressLauncher rtc.EgressLauncher
|
||||
}
|
||||
|
||||
func NewRoomService(ra RoomAllocator, rs ServiceStore, router routing.MessageRouter, conf config.RoomConfig) (svc *RoomService, err error) {
|
||||
func NewRoomService(
|
||||
conf config.RoomConfig,
|
||||
router routing.MessageRouter,
|
||||
roomAllocator RoomAllocator,
|
||||
serviceStore ServiceStore,
|
||||
egressLauncher rtc.EgressLauncher,
|
||||
) (svc *RoomService, err error) {
|
||||
|
||||
svc = &RoomService{
|
||||
router: router,
|
||||
roomAllocator: ra,
|
||||
roomStore: rs,
|
||||
conf: conf,
|
||||
conf: conf,
|
||||
router: router,
|
||||
roomAllocator: roomAllocator,
|
||||
roomStore: serviceStore,
|
||||
egressLauncher: egressLauncher,
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -41,11 +51,28 @@ func NewRoomService(ra RoomAllocator, rs ServiceStore, router routing.MessageRou
|
||||
func (s *RoomService) CreateRoom(ctx context.Context, req *livekit.CreateRoomRequest) (rm *livekit.Room, err error) {
|
||||
if err = EnsureCreatePermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
} else if req.Egress != nil {
|
||||
if s.egressLauncher == nil {
|
||||
return nil, ErrEgressNotConnected
|
||||
} else if err = EnsureRecordPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
}
|
||||
}
|
||||
|
||||
rm, err = s.roomAllocator.CreateRoom(ctx, req)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "could not create room")
|
||||
return
|
||||
}
|
||||
|
||||
if req.Egress != nil && req.Egress.Room != nil {
|
||||
egress := &livekit.StartEgressRequest{
|
||||
Request: &livekit.StartEgressRequest_RoomComposite{
|
||||
RoomComposite: req.Egress.Room,
|
||||
},
|
||||
RoomId: rm.Sid,
|
||||
}
|
||||
_, err = s.egressLauncher.StartEgress(ctx, egress)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -107,7 +107,7 @@ func newTestRoomService(conf config.RoomConfig) *TestRoomService {
|
||||
router := &routingfakes.FakeRouter{}
|
||||
allocator := &servicefakes.FakeRoomAllocator{}
|
||||
store := &servicefakes.FakeServiceStore{}
|
||||
svc, err := service.NewRoomService(allocator, store, router, conf)
|
||||
svc, err := service.NewRoomService(conf, router, allocator, store, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -93,6 +93,20 @@ type FakeObjectStore struct {
|
||||
result1 *livekit.Room
|
||||
result2 error
|
||||
}
|
||||
LoadRoomInternalStub func(context.Context, livekit.RoomName) (*livekit.RoomInternal, error)
|
||||
loadRoomInternalMutex sync.RWMutex
|
||||
loadRoomInternalArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
}
|
||||
loadRoomInternalReturns struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}
|
||||
loadRoomInternalReturnsOnCall map[int]struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}
|
||||
LockRoomStub func(context.Context, livekit.RoomName, time.Duration) (string, error)
|
||||
lockRoomMutex sync.RWMutex
|
||||
lockRoomArgsForCall []struct {
|
||||
@@ -133,6 +147,19 @@ type FakeObjectStore struct {
|
||||
storeRoomReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
StoreRoomInternalStub func(context.Context, livekit.RoomName, *livekit.RoomInternal) error
|
||||
storeRoomInternalMutex sync.RWMutex
|
||||
storeRoomInternalArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
arg3 *livekit.RoomInternal
|
||||
}
|
||||
storeRoomInternalReturns struct {
|
||||
result1 error
|
||||
}
|
||||
storeRoomInternalReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
UnlockRoomStub func(context.Context, livekit.RoomName, string) error
|
||||
unlockRoomMutex sync.RWMutex
|
||||
unlockRoomArgsForCall []struct {
|
||||
@@ -541,6 +568,71 @@ func (fake *FakeObjectStore) LoadRoomReturnsOnCall(i int, result1 *livekit.Room,
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LoadRoomInternal(arg1 context.Context, arg2 livekit.RoomName) (*livekit.RoomInternal, error) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
ret, specificReturn := fake.loadRoomInternalReturnsOnCall[len(fake.loadRoomInternalArgsForCall)]
|
||||
fake.loadRoomInternalArgsForCall = append(fake.loadRoomInternalArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
}{arg1, arg2})
|
||||
stub := fake.LoadRoomInternalStub
|
||||
fakeReturns := fake.loadRoomInternalReturns
|
||||
fake.recordInvocation("LoadRoomInternal", []interface{}{arg1, arg2})
|
||||
fake.loadRoomInternalMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2
|
||||
}
|
||||
return fakeReturns.result1, fakeReturns.result2
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LoadRoomInternalCallCount() int {
|
||||
fake.loadRoomInternalMutex.RLock()
|
||||
defer fake.loadRoomInternalMutex.RUnlock()
|
||||
return len(fake.loadRoomInternalArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LoadRoomInternalCalls(stub func(context.Context, livekit.RoomName) (*livekit.RoomInternal, error)) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
defer fake.loadRoomInternalMutex.Unlock()
|
||||
fake.LoadRoomInternalStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LoadRoomInternalArgsForCall(i int) (context.Context, livekit.RoomName) {
|
||||
fake.loadRoomInternalMutex.RLock()
|
||||
defer fake.loadRoomInternalMutex.RUnlock()
|
||||
argsForCall := fake.loadRoomInternalArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LoadRoomInternalReturns(result1 *livekit.RoomInternal, result2 error) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
defer fake.loadRoomInternalMutex.Unlock()
|
||||
fake.LoadRoomInternalStub = nil
|
||||
fake.loadRoomInternalReturns = struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LoadRoomInternalReturnsOnCall(i int, result1 *livekit.RoomInternal, result2 error) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
defer fake.loadRoomInternalMutex.Unlock()
|
||||
fake.LoadRoomInternalStub = nil
|
||||
if fake.loadRoomInternalReturnsOnCall == nil {
|
||||
fake.loadRoomInternalReturnsOnCall = make(map[int]struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.loadRoomInternalReturnsOnCall[i] = struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) LockRoom(arg1 context.Context, arg2 livekit.RoomName, arg3 time.Duration) (string, error) {
|
||||
fake.lockRoomMutex.Lock()
|
||||
ret, specificReturn := fake.lockRoomReturnsOnCall[len(fake.lockRoomArgsForCall)]
|
||||
@@ -732,6 +824,69 @@ func (fake *FakeObjectStore) StoreRoomReturnsOnCall(i int, result1 error) {
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) StoreRoomInternal(arg1 context.Context, arg2 livekit.RoomName, arg3 *livekit.RoomInternal) error {
|
||||
fake.storeRoomInternalMutex.Lock()
|
||||
ret, specificReturn := fake.storeRoomInternalReturnsOnCall[len(fake.storeRoomInternalArgsForCall)]
|
||||
fake.storeRoomInternalArgsForCall = append(fake.storeRoomInternalArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
arg3 *livekit.RoomInternal
|
||||
}{arg1, arg2, arg3})
|
||||
stub := fake.StoreRoomInternalStub
|
||||
fakeReturns := fake.storeRoomInternalReturns
|
||||
fake.recordInvocation("StoreRoomInternal", []interface{}{arg1, arg2, arg3})
|
||||
fake.storeRoomInternalMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2, arg3)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) StoreRoomInternalCallCount() int {
|
||||
fake.storeRoomInternalMutex.RLock()
|
||||
defer fake.storeRoomInternalMutex.RUnlock()
|
||||
return len(fake.storeRoomInternalArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) StoreRoomInternalCalls(stub func(context.Context, livekit.RoomName, *livekit.RoomInternal) error) {
|
||||
fake.storeRoomInternalMutex.Lock()
|
||||
defer fake.storeRoomInternalMutex.Unlock()
|
||||
fake.StoreRoomInternalStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) StoreRoomInternalArgsForCall(i int) (context.Context, livekit.RoomName, *livekit.RoomInternal) {
|
||||
fake.storeRoomInternalMutex.RLock()
|
||||
defer fake.storeRoomInternalMutex.RUnlock()
|
||||
argsForCall := fake.storeRoomInternalArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) StoreRoomInternalReturns(result1 error) {
|
||||
fake.storeRoomInternalMutex.Lock()
|
||||
defer fake.storeRoomInternalMutex.Unlock()
|
||||
fake.StoreRoomInternalStub = nil
|
||||
fake.storeRoomInternalReturns = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) StoreRoomInternalReturnsOnCall(i int, result1 error) {
|
||||
fake.storeRoomInternalMutex.Lock()
|
||||
defer fake.storeRoomInternalMutex.Unlock()
|
||||
fake.StoreRoomInternalStub = nil
|
||||
if fake.storeRoomInternalReturnsOnCall == nil {
|
||||
fake.storeRoomInternalReturnsOnCall = make(map[int]struct {
|
||||
result1 error
|
||||
})
|
||||
}
|
||||
fake.storeRoomInternalReturnsOnCall[i] = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) UnlockRoom(arg1 context.Context, arg2 livekit.RoomName, arg3 string) error {
|
||||
fake.unlockRoomMutex.Lock()
|
||||
ret, specificReturn := fake.unlockRoomReturnsOnCall[len(fake.unlockRoomArgsForCall)]
|
||||
@@ -810,12 +965,16 @@ func (fake *FakeObjectStore) Invocations() map[string][][]interface{} {
|
||||
defer fake.loadParticipantMutex.RUnlock()
|
||||
fake.loadRoomMutex.RLock()
|
||||
defer fake.loadRoomMutex.RUnlock()
|
||||
fake.loadRoomInternalMutex.RLock()
|
||||
defer fake.loadRoomInternalMutex.RUnlock()
|
||||
fake.lockRoomMutex.RLock()
|
||||
defer fake.lockRoomMutex.RUnlock()
|
||||
fake.storeParticipantMutex.RLock()
|
||||
defer fake.storeParticipantMutex.RUnlock()
|
||||
fake.storeRoomMutex.RLock()
|
||||
defer fake.storeRoomMutex.RUnlock()
|
||||
fake.storeRoomInternalMutex.RLock()
|
||||
defer fake.storeRoomInternalMutex.RUnlock()
|
||||
fake.unlockRoomMutex.RLock()
|
||||
defer fake.unlockRoomMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
|
||||
@@ -67,6 +67,20 @@ type FakeServiceStore struct {
|
||||
result1 *livekit.Room
|
||||
result2 error
|
||||
}
|
||||
LoadRoomInternalStub func(context.Context, livekit.RoomName) (*livekit.RoomInternal, error)
|
||||
loadRoomInternalMutex sync.RWMutex
|
||||
loadRoomInternalArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
}
|
||||
loadRoomInternalReturns struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}
|
||||
loadRoomInternalReturnsOnCall map[int]struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}
|
||||
invocations map[string][][]interface{}
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
@@ -337,6 +351,71 @@ func (fake *FakeServiceStore) LoadRoomReturnsOnCall(i int, result1 *livekit.Room
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) LoadRoomInternal(arg1 context.Context, arg2 livekit.RoomName) (*livekit.RoomInternal, error) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
ret, specificReturn := fake.loadRoomInternalReturnsOnCall[len(fake.loadRoomInternalArgsForCall)]
|
||||
fake.loadRoomInternalArgsForCall = append(fake.loadRoomInternalArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
}{arg1, arg2})
|
||||
stub := fake.LoadRoomInternalStub
|
||||
fakeReturns := fake.loadRoomInternalReturns
|
||||
fake.recordInvocation("LoadRoomInternal", []interface{}{arg1, arg2})
|
||||
fake.loadRoomInternalMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2
|
||||
}
|
||||
return fakeReturns.result1, fakeReturns.result2
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) LoadRoomInternalCallCount() int {
|
||||
fake.loadRoomInternalMutex.RLock()
|
||||
defer fake.loadRoomInternalMutex.RUnlock()
|
||||
return len(fake.loadRoomInternalArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) LoadRoomInternalCalls(stub func(context.Context, livekit.RoomName) (*livekit.RoomInternal, error)) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
defer fake.loadRoomInternalMutex.Unlock()
|
||||
fake.LoadRoomInternalStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) LoadRoomInternalArgsForCall(i int) (context.Context, livekit.RoomName) {
|
||||
fake.loadRoomInternalMutex.RLock()
|
||||
defer fake.loadRoomInternalMutex.RUnlock()
|
||||
argsForCall := fake.loadRoomInternalArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) LoadRoomInternalReturns(result1 *livekit.RoomInternal, result2 error) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
defer fake.loadRoomInternalMutex.Unlock()
|
||||
fake.LoadRoomInternalStub = nil
|
||||
fake.loadRoomInternalReturns = struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) LoadRoomInternalReturnsOnCall(i int, result1 *livekit.RoomInternal, result2 error) {
|
||||
fake.loadRoomInternalMutex.Lock()
|
||||
defer fake.loadRoomInternalMutex.Unlock()
|
||||
fake.LoadRoomInternalStub = nil
|
||||
if fake.loadRoomInternalReturnsOnCall == nil {
|
||||
fake.loadRoomInternalReturnsOnCall = make(map[int]struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.loadRoomInternalReturnsOnCall[i] = struct {
|
||||
result1 *livekit.RoomInternal
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
@@ -348,6 +427,8 @@ func (fake *FakeServiceStore) Invocations() map[string][][]interface{} {
|
||||
defer fake.loadParticipantMutex.RUnlock()
|
||||
fake.loadRoomMutex.RLock()
|
||||
defer fake.loadRoomMutex.RUnlock()
|
||||
fake.loadRoomInternalMutex.RLock()
|
||||
defer fake.loadRoomInternalMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
for key, value := range fake.invocations {
|
||||
copiedInvocations[key] = value
|
||||
|
||||
@@ -45,6 +45,7 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
||||
telemetry.NewTelemetryService,
|
||||
egress.NewRedisRPCClient,
|
||||
getEgressStore,
|
||||
NewEgressLauncher,
|
||||
NewEgressService,
|
||||
ingress.NewRedisRPC,
|
||||
getIngressStore,
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
// Injectors from wire.go:
|
||||
|
||||
func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*LivekitServer, error) {
|
||||
roomConfig := getRoomConf(conf)
|
||||
client, err := createRedisClient(conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -44,11 +45,6 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
roomConfig := getRoomConf(conf)
|
||||
roomService, err := NewRoomService(roomAllocator, objectStore, router, roomConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nodeID := getNodeID(currentNode)
|
||||
rpcClient := egress.NewRedisRPCClient(nodeID, client)
|
||||
egressStore := getEgressStore(objectStore)
|
||||
@@ -62,7 +58,12 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
||||
}
|
||||
analyticsService := telemetry.NewAnalyticsService(conf, currentNode)
|
||||
telemetryService := telemetry.NewTelemetryService(notifier, analyticsService)
|
||||
egressService := NewEgressService(rpcClient, objectStore, egressStore, roomService, telemetryService)
|
||||
rtcEgressLauncher := NewEgressLauncher(rpcClient, egressStore, telemetryService)
|
||||
roomService, err := NewRoomService(roomConfig, router, roomAllocator, objectStore, rtcEgressLauncher)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
egressService := NewEgressService(rpcClient, objectStore, egressStore, roomService, telemetryService, rtcEgressLauncher)
|
||||
ingressConfig := getIngressConfig(conf)
|
||||
rpc := ingress.NewRedisRPC(nodeID, client)
|
||||
ingressRPCClient := getIngressRPCClient(rpc)
|
||||
@@ -70,7 +71,7 @@ func InitializeServer(conf *config.Config, currentNode routing.LocalNode) (*Live
|
||||
ingressService := NewIngressService(ingressConfig, ingressRPCClient, ingressStore, roomService, telemetryService)
|
||||
rtcService := NewRTCService(conf, roomAllocator, objectStore, router, currentNode)
|
||||
clientConfigurationManager := createClientConfiguration()
|
||||
roomManager, err := NewLocalRoomManager(conf, objectStore, currentNode, router, telemetryService, clientConfigurationManager)
|
||||
roomManager, err := NewLocalRoomManager(conf, objectStore, currentNode, router, telemetryService, clientConfigurationManager, rtcEgressLauncher)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user