mirror of
https://github.com/livekit/livekit.git
synced 2026-03-30 17:45:40 +00:00
move delete to oss service store (#4164)
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
//counterfeiter:generate . ObjectStore
|
||||
type ObjectStore interface {
|
||||
ServiceStore
|
||||
OSSServiceStore
|
||||
|
||||
// enable locking on a specific room to prevent race
|
||||
// returns a (lock uuid, error)
|
||||
@@ -43,7 +44,6 @@ type ObjectStore interface {
|
||||
//counterfeiter:generate . ServiceStore
|
||||
type ServiceStore interface {
|
||||
LoadRoom(ctx context.Context, roomName livekit.RoomName, includeInternal bool) (*livekit.Room, *livekit.RoomInternal, error)
|
||||
DeleteRoom(ctx context.Context, roomName livekit.RoomName) error
|
||||
|
||||
// ListRooms returns currently active rooms. if names is not nil, it'll filter and return
|
||||
// only rooms that match
|
||||
@@ -53,6 +53,7 @@ type ServiceStore interface {
|
||||
}
|
||||
|
||||
type OSSServiceStore interface {
|
||||
DeleteRoom(ctx context.Context, roomName livekit.RoomName) error
|
||||
HasParticipant(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (bool, error)
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,9 @@ func (s *RoomService) DeleteRoom(ctx context.Context, req *livekit.DeleteRoomReq
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.roomStore.DeleteRoom(ctx, livekit.RoomName(req.Room))
|
||||
if os, ok := s.roomStore.(OSSServiceStore); ok {
|
||||
err = os.DeleteRoom(ctx, livekit.RoomName(req.Room))
|
||||
}
|
||||
res := &livekit.DeleteRoomResponse{}
|
||||
RecordResponse(ctx, room)
|
||||
return res, err
|
||||
|
||||
@@ -36,6 +36,21 @@ type FakeObjectStore struct {
|
||||
deleteRoomReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
HasParticipantStub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (bool, error)
|
||||
hasParticipantMutex sync.RWMutex
|
||||
hasParticipantArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
arg3 livekit.ParticipantIdentity
|
||||
}
|
||||
hasParticipantReturns struct {
|
||||
result1 bool
|
||||
result2 error
|
||||
}
|
||||
hasParticipantReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
result2 error
|
||||
}
|
||||
ListParticipantsStub func(context.Context, livekit.RoomName) ([]*livekit.ParticipantInfo, error)
|
||||
listParticipantsMutex sync.RWMutex
|
||||
listParticipantsArgsForCall []struct {
|
||||
@@ -279,6 +294,72 @@ func (fake *FakeObjectStore) DeleteRoomReturnsOnCall(i int, result1 error) {
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) HasParticipant(arg1 context.Context, arg2 livekit.RoomName, arg3 livekit.ParticipantIdentity) (bool, error) {
|
||||
fake.hasParticipantMutex.Lock()
|
||||
ret, specificReturn := fake.hasParticipantReturnsOnCall[len(fake.hasParticipantArgsForCall)]
|
||||
fake.hasParticipantArgsForCall = append(fake.hasParticipantArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
arg3 livekit.ParticipantIdentity
|
||||
}{arg1, arg2, arg3})
|
||||
stub := fake.HasParticipantStub
|
||||
fakeReturns := fake.hasParticipantReturns
|
||||
fake.recordInvocation("HasParticipant", []interface{}{arg1, arg2, arg3})
|
||||
fake.hasParticipantMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2, arg3)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2
|
||||
}
|
||||
return fakeReturns.result1, fakeReturns.result2
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) HasParticipantCallCount() int {
|
||||
fake.hasParticipantMutex.RLock()
|
||||
defer fake.hasParticipantMutex.RUnlock()
|
||||
return len(fake.hasParticipantArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) HasParticipantCalls(stub func(context.Context, livekit.RoomName, livekit.ParticipantIdentity) (bool, error)) {
|
||||
fake.hasParticipantMutex.Lock()
|
||||
defer fake.hasParticipantMutex.Unlock()
|
||||
fake.HasParticipantStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) HasParticipantArgsForCall(i int) (context.Context, livekit.RoomName, livekit.ParticipantIdentity) {
|
||||
fake.hasParticipantMutex.RLock()
|
||||
defer fake.hasParticipantMutex.RUnlock()
|
||||
argsForCall := fake.hasParticipantArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) HasParticipantReturns(result1 bool, result2 error) {
|
||||
fake.hasParticipantMutex.Lock()
|
||||
defer fake.hasParticipantMutex.Unlock()
|
||||
fake.HasParticipantStub = nil
|
||||
fake.hasParticipantReturns = struct {
|
||||
result1 bool
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) HasParticipantReturnsOnCall(i int, result1 bool, result2 error) {
|
||||
fake.hasParticipantMutex.Lock()
|
||||
defer fake.hasParticipantMutex.Unlock()
|
||||
fake.HasParticipantStub = nil
|
||||
if fake.hasParticipantReturnsOnCall == nil {
|
||||
fake.hasParticipantReturnsOnCall = make(map[int]struct {
|
||||
result1 bool
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.hasParticipantReturnsOnCall[i] = struct {
|
||||
result1 bool
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *FakeObjectStore) ListParticipants(arg1 context.Context, arg2 livekit.RoomName) ([]*livekit.ParticipantInfo, error) {
|
||||
fake.listParticipantsMutex.Lock()
|
||||
ret, specificReturn := fake.listParticipantsReturnsOnCall[len(fake.listParticipantsArgsForCall)]
|
||||
|
||||
@@ -10,18 +10,6 @@ import (
|
||||
)
|
||||
|
||||
type FakeServiceStore struct {
|
||||
DeleteRoomStub func(context.Context, livekit.RoomName) error
|
||||
deleteRoomMutex sync.RWMutex
|
||||
deleteRoomArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
}
|
||||
deleteRoomReturns struct {
|
||||
result1 error
|
||||
}
|
||||
deleteRoomReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
ListParticipantsStub func(context.Context, livekit.RoomName) ([]*livekit.ParticipantInfo, error)
|
||||
listParticipantsMutex sync.RWMutex
|
||||
listParticipantsArgsForCall []struct {
|
||||
@@ -86,68 +74,6 @@ type FakeServiceStore struct {
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) DeleteRoom(arg1 context.Context, arg2 livekit.RoomName) error {
|
||||
fake.deleteRoomMutex.Lock()
|
||||
ret, specificReturn := fake.deleteRoomReturnsOnCall[len(fake.deleteRoomArgsForCall)]
|
||||
fake.deleteRoomArgsForCall = append(fake.deleteRoomArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 livekit.RoomName
|
||||
}{arg1, arg2})
|
||||
stub := fake.DeleteRoomStub
|
||||
fakeReturns := fake.deleteRoomReturns
|
||||
fake.recordInvocation("DeleteRoom", []interface{}{arg1, arg2})
|
||||
fake.deleteRoomMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) DeleteRoomCallCount() int {
|
||||
fake.deleteRoomMutex.RLock()
|
||||
defer fake.deleteRoomMutex.RUnlock()
|
||||
return len(fake.deleteRoomArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) DeleteRoomCalls(stub func(context.Context, livekit.RoomName) error) {
|
||||
fake.deleteRoomMutex.Lock()
|
||||
defer fake.deleteRoomMutex.Unlock()
|
||||
fake.DeleteRoomStub = stub
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) DeleteRoomArgsForCall(i int) (context.Context, livekit.RoomName) {
|
||||
fake.deleteRoomMutex.RLock()
|
||||
defer fake.deleteRoomMutex.RUnlock()
|
||||
argsForCall := fake.deleteRoomArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) DeleteRoomReturns(result1 error) {
|
||||
fake.deleteRoomMutex.Lock()
|
||||
defer fake.deleteRoomMutex.Unlock()
|
||||
fake.DeleteRoomStub = nil
|
||||
fake.deleteRoomReturns = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) DeleteRoomReturnsOnCall(i int, result1 error) {
|
||||
fake.deleteRoomMutex.Lock()
|
||||
defer fake.deleteRoomMutex.Unlock()
|
||||
fake.DeleteRoomStub = nil
|
||||
if fake.deleteRoomReturnsOnCall == nil {
|
||||
fake.deleteRoomReturnsOnCall = make(map[int]struct {
|
||||
result1 error
|
||||
})
|
||||
}
|
||||
fake.deleteRoomReturnsOnCall[i] = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *FakeServiceStore) ListParticipants(arg1 context.Context, arg2 livekit.RoomName) ([]*livekit.ParticipantInfo, error) {
|
||||
fake.listParticipantsMutex.Lock()
|
||||
ret, specificReturn := fake.listParticipantsReturnsOnCall[len(fake.listParticipantsArgsForCall)]
|
||||
|
||||
Reference in New Issue
Block a user