Some more files with types (#302)

This commit is contained in:
Raja Subramanian
2021-12-30 16:43:20 +05:30
committed by GitHub
parent 1b66fe1e23
commit 07db1ba726
14 changed files with 109 additions and 105 deletions
+9 -9
View File
@@ -54,7 +54,7 @@ func (p *RedisRoomStore) StoreRoom(_ context.Context, room *livekit.Room) error
return nil
}
func (p *RedisRoomStore) LoadRoom(_ context.Context, name string) (*livekit.Room, error) {
func (p *RedisRoomStore) LoadRoom(_ context.Context, name livekit.RoomName) (*livekit.Room, error) {
data, err := p.rc.HGet(p.ctx, RoomsKey, name).Result()
if err != nil {
if err == redis.Nil {
@@ -72,7 +72,7 @@ func (p *RedisRoomStore) LoadRoom(_ context.Context, name string) (*livekit.Room
return &room, nil
}
func (p *RedisRoomStore) ListRooms(_ context.Context, names []string) ([]*livekit.Room, error) {
func (p *RedisRoomStore) ListRooms(_ context.Context, names []livekit.RoomName) ([]*livekit.Room, error) {
var items []string
var err error
if names == nil {
@@ -106,7 +106,7 @@ func (p *RedisRoomStore) ListRooms(_ context.Context, names []string) ([]*liveki
return rooms, nil
}
func (p *RedisRoomStore) DeleteRoom(ctx context.Context, name string) error {
func (p *RedisRoomStore) DeleteRoom(ctx context.Context, name livekit.RoomName) error {
_, err := p.LoadRoom(ctx, name)
if err == ErrRoomNotFound {
return nil
@@ -120,7 +120,7 @@ func (p *RedisRoomStore) DeleteRoom(ctx context.Context, name string) error {
return err
}
func (p *RedisRoomStore) LockRoom(_ context.Context, name string, duration time.Duration) (string, error) {
func (p *RedisRoomStore) LockRoom(_ context.Context, name livekit.RoomName, duration time.Duration) (string, error) {
token := utils.NewGuid("LOCK")
key := RoomLockPrefix + name
@@ -145,7 +145,7 @@ func (p *RedisRoomStore) LockRoom(_ context.Context, name string, duration time.
return "", ErrRoomLockFailed
}
func (p *RedisRoomStore) UnlockRoom(_ context.Context, name string, uid string) error {
func (p *RedisRoomStore) UnlockRoom(_ context.Context, name livekit.RoomName, uid string) error {
key := RoomLockPrefix + name
val, err := p.rc.Get(p.ctx, key).Result()
@@ -162,7 +162,7 @@ func (p *RedisRoomStore) UnlockRoom(_ context.Context, name string, uid string)
return p.rc.Del(p.ctx, key).Err()
}
func (p *RedisRoomStore) StoreParticipant(_ context.Context, roomName string, participant *livekit.ParticipantInfo) error {
func (p *RedisRoomStore) StoreParticipant(_ context.Context, roomName livekit.RoomName, participant *livekit.ParticipantInfo) error {
key := RoomParticipantsPrefix + roomName
data, err := proto.Marshal(participant)
@@ -173,7 +173,7 @@ func (p *RedisRoomStore) StoreParticipant(_ context.Context, roomName string, pa
return p.rc.HSet(p.ctx, key, participant.Identity, data).Err()
}
func (p *RedisRoomStore) LoadParticipant(_ context.Context, roomName, identity string) (*livekit.ParticipantInfo, error) {
func (p *RedisRoomStore) LoadParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) (*livekit.ParticipantInfo, error) {
key := RoomParticipantsPrefix + roomName
data, err := p.rc.HGet(p.ctx, key, identity).Result()
if err == redis.Nil {
@@ -189,7 +189,7 @@ func (p *RedisRoomStore) LoadParticipant(_ context.Context, roomName, identity s
return &pi, nil
}
func (p *RedisRoomStore) ListParticipants(_ context.Context, roomName string) ([]*livekit.ParticipantInfo, error) {
func (p *RedisRoomStore) ListParticipants(_ context.Context, roomName livekit.RoomName) ([]*livekit.ParticipantInfo, error) {
key := RoomParticipantsPrefix + roomName
items, err := p.rc.HVals(p.ctx, key).Result()
if err == redis.Nil {
@@ -209,7 +209,7 @@ func (p *RedisRoomStore) ListParticipants(_ context.Context, roomName string) ([
return participants, nil
}
func (p *RedisRoomStore) DeleteParticipant(_ context.Context, roomName, identity string) error {
func (p *RedisRoomStore) DeleteParticipant(_ context.Context, roomName livekit.RoomName, identity livekit.ParticipantIdentity) error {
key := RoomParticipantsPrefix + roomName
return p.rc.HDel(p.ctx, key, identity).Err()