Documentation ¶
Index ¶
- Constants
- Variables
- type RedisChatStore
- func (r *RedisChatStore) AddChat(ctx context.Context, ...) (*pb.ChatMessage, error)
- func (r *RedisChatStore) DeleteChat(ctx context.Context, channel, msgID string) error
- func (r *RedisChatStore) EventChan() chan *entity.EventWrapper
- func (r *RedisChatStore) GetChat(ctx context.Context, channel, msgID string) (*pb.ChatMessage, error)
- func (r *RedisChatStore) LatestChannels(ctx context.Context, count, offset int, uid, tournamentID string) (*upb.ActiveChatChannels, error)
- func (r *RedisChatStore) OldChats(ctx context.Context, channel string, n int) ([]*pb.ChatMessage, error)
- func (r *RedisChatStore) SetEventChan(c chan *entity.EventWrapper)
- type RedisPresenceStore
- func (s *RedisPresenceStore) BatchGetChannels(ctx context.Context, uuids []string) ([][]string, error)
- func (s *RedisPresenceStore) BatchGetPresence(ctx context.Context, users []*entity.User) ([]*entity.User, error)
- func (s *RedisPresenceStore) ClearPresence(ctx context.Context, uuid, username string, anon bool, connID string) ([]string, []string, []string, error)
- func (s *RedisPresenceStore) CountInChannel(ctx context.Context, channel string) (int, error)
- func (s *RedisPresenceStore) EventChan() chan *entity.EventWrapper
- func (s *RedisPresenceStore) GetInChannel(ctx context.Context, channel string) ([]*entity.User, error)
- func (s *RedisPresenceStore) GetPresence(ctx context.Context, uuid string) ([]string, error)
- func (s *RedisPresenceStore) LastSeen(ctx context.Context, uuid string) (int64, error)
- func (s *RedisPresenceStore) RenewPresence(ctx context.Context, userID, username string, anon bool, connID string) ([]string, []string, error)
- func (s *RedisPresenceStore) SetEventChan(c chan *entity.EventWrapper)
- func (s *RedisPresenceStore) SetPresence(ctx context.Context, uuid, username string, anon bool, channel, connID string) ([]string, []string, error)
- func (s *RedisPresenceStore) UpdateActiveGame(ctx context.Context, activeGameEntry *pb.ActiveGameEntry) ([][][]string, error)
- func (s *RedisPresenceStore) UpdateFollower(ctx context.Context, followee, follower *entity.User, following bool) error
Constants ¶
const ChatPreviewLength = 40
const ChatsOnReload = 100
const GameChatChannelExpiration = 86400
const LatestChatSeparator = ":"
const LobbyChatChannel = "chat.lobby"
const LongChannelExpiration = 86400 * 14
const (
NullPresenceChannel = "NULL"
)
Variables ¶
var AddChatScript string
var ClearPresenceScript string
ClearPresenceScript clears the presence and returns the channel(s) it was in.
var GetChannelsScript string
GetChannelsScript gets the channels
var LatestChannelsScript string
var RenewPresenceScript string
RenewPresenceScript renews the presence
var SetPresenceScript string
SetPresenceScript is a Lua script that handles presence in an atomic way. We may want to move this to a separate file if we start adding more Lua scripts.
var UpdateActiveGameScript string
updateActiveGameScript gets the channels
Functions ¶
This section is empty.
Types ¶
type RedisChatStore ¶
type RedisChatStore struct {
// contains filtered or unexported fields
}
RedisChatStore implements a Redis store for chats.
func NewRedisChatStore ¶
func NewRedisChatStore(r *redis.Pool, p user.PresenceStore, t tournament.TournamentStore) *RedisChatStore
NewRedisChatStore instantiates a new store for chats, based on Redis.
func (*RedisChatStore) AddChat ¶
func (r *RedisChatStore) AddChat(ctx context.Context, senderUsername, senderUID, msg, channel, channelFriendly string, regulateChat bool) (*pb.ChatMessage, error)
AddChat takes in sender information, the message, and the name of the channel. Additionally, a user-readable name for the channel should be provided.
func (*RedisChatStore) DeleteChat ¶
func (r *RedisChatStore) DeleteChat(ctx context.Context, channel, msgID string) error
DeleteChat deletes a chat.
func (*RedisChatStore) EventChan ¶
func (r *RedisChatStore) EventChan() chan *entity.EventWrapper
func (*RedisChatStore) GetChat ¶
func (r *RedisChatStore) GetChat(ctx context.Context, channel, msgID string) (*pb.ChatMessage, error)
func (*RedisChatStore) LatestChannels ¶
func (r *RedisChatStore) LatestChannels(ctx context.Context, count, offset int, uid, tournamentID string) (*upb.ActiveChatChannels, error)
LatestChannels returns a list of channel names for the given user. These channels should be sorted in time order starting with the most recent. The time associated with each channel is the time of the latest message sent in that channel. If a non-blank tournamentID is passed, we force this function to return the chat channel for the given tournament ID, even if the user has not yet chatted in it.
func (*RedisChatStore) OldChats ¶
func (r *RedisChatStore) OldChats(ctx context.Context, channel string, n int) ([]*pb.ChatMessage, error)
func (*RedisChatStore) SetEventChan ¶
func (r *RedisChatStore) SetEventChan(c chan *entity.EventWrapper)
type RedisPresenceStore ¶
type RedisPresenceStore struct {
// contains filtered or unexported fields
}
RedisPresenceStore implements a Redis store for user presence.
func NewRedisPresenceStore ¶
func NewRedisPresenceStore(r *redis.Pool) *RedisPresenceStore
func (*RedisPresenceStore) BatchGetChannels ¶
func (*RedisPresenceStore) BatchGetPresence ¶
func (*RedisPresenceStore) ClearPresence ¶
func (*RedisPresenceStore) CountInChannel ¶
func (*RedisPresenceStore) EventChan ¶
func (s *RedisPresenceStore) EventChan() chan *entity.EventWrapper
func (*RedisPresenceStore) GetInChannel ¶
func (*RedisPresenceStore) GetPresence ¶
Get the current channels the given user is in. Return empty for no channel.
func (*RedisPresenceStore) RenewPresence ¶
func (*RedisPresenceStore) SetEventChan ¶
func (s *RedisPresenceStore) SetEventChan(c chan *entity.EventWrapper)
func (*RedisPresenceStore) SetPresence ¶
func (s *RedisPresenceStore) SetPresence(ctx context.Context, uuid, username string, anon bool, channel, connID string) ([]string, []string, error)
SetPresence sets the user's presence channel.
func (*RedisPresenceStore) UpdateActiveGame ¶
func (s *RedisPresenceStore) UpdateActiveGame(ctx context.Context, activeGameEntry *pb.ActiveGameEntry) ([][][]string, error)