redis

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ChatPreviewLength = 40
View Source
const ChatsOnReload = 100
View Source
const GameChatChannelExpiration = 86400
View Source
const LatestChatSeparator = ":"
View Source
const LobbyChatChannel = "chat.lobby"
View Source
const LongChannelExpiration = 86400 * 14
View Source
const (
	NullPresenceChannel = "NULL"
)

Variables

View Source
var AddChatScript string
View Source
var ClearPresenceScript string

ClearPresenceScript clears the presence and returns the channel(s) it was in.

View Source
var GetChannelsScript string

GetChannelsScript gets the channels

View Source
var LatestChannelsScript string
View Source
var RenewPresenceScript string

RenewPresenceScript renews the presence

View Source
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.

View Source
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

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 (s *RedisPresenceStore) BatchGetChannels(ctx context.Context, uuids []string) ([][]string, error)

func (*RedisPresenceStore) BatchGetPresence

func (s *RedisPresenceStore) BatchGetPresence(ctx context.Context, users []*entity.User) ([]*entity.User, error)

func (*RedisPresenceStore) ClearPresence

func (s *RedisPresenceStore) ClearPresence(ctx context.Context, uuid, username string,
	anon bool, connID string) ([]string, []string, []string, error)

func (*RedisPresenceStore) CountInChannel

func (s *RedisPresenceStore) CountInChannel(ctx context.Context, channel string) (int, error)

func (*RedisPresenceStore) EventChan

func (s *RedisPresenceStore) EventChan() chan *entity.EventWrapper

func (*RedisPresenceStore) GetInChannel

func (s *RedisPresenceStore) GetInChannel(ctx context.Context, channel string) ([]*entity.User, error)

func (*RedisPresenceStore) GetPresence

func (s *RedisPresenceStore) GetPresence(ctx context.Context, uuid string) ([]string, error)

Get the current channels the given user is in. Return empty for no channel.

func (*RedisPresenceStore) LastSeen

func (s *RedisPresenceStore) LastSeen(ctx context.Context, uuid string) (int64, error)

func (*RedisPresenceStore) RenewPresence

func (s *RedisPresenceStore) RenewPresence(ctx context.Context, userID, username string,
	anon bool, connID string) ([]string, []string, error)

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)

func (*RedisPresenceStore) UpdateFollower

func (s *RedisPresenceStore) UpdateFollower(ctx context.Context, followee, follower *entity.User, following bool) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL