tournament

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Increase this if we ever think we might be holding more than
	// 50 tournaments at a time.
	CacheCap = 50
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Cache will reside in-memory, and will be per-node.

func NewCache

func NewCache(backing backingStore) *Cache

func (*Cache) ActiveTournamentsFor

func (c *Cache) ActiveTournamentsFor(ctx context.Context, userID string) ([][2]string, error)

func (*Cache) AddRegistrants

func (c *Cache) AddRegistrants(ctx context.Context, tid string, userIDs []string, division string) error

func (*Cache) Create

func (c *Cache) Create(ctx context.Context, tm *entity.Tournament) error

Create creates the tournament in the cache as well as the store.

func (*Cache) Disconnect

func (c *Cache) Disconnect()

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, id string) (*entity.Tournament, error)

Get gets a tournament from the cache. It loads it into the cache if it's not there.

func (*Cache) GetBySlug

func (c *Cache) GetBySlug(ctx context.Context, id string) (*entity.Tournament, error)

func (*Cache) GetRecentClubSessions

func (c *Cache) GetRecentClubSessions(ctx context.Context, clubID string, numSessions int, offset int) (*pb.ClubSessionsResponse, error)

func (*Cache) GetRecentGames

func (c *Cache) GetRecentGames(ctx context.Context, tourneyID string, numGames int, offset int) (*pb.RecentGamesResponse, error)

func (*Cache) ListAllIDs

func (c *Cache) ListAllIDs(ctx context.Context) ([]string, error)

func (*Cache) RemoveRegistrants

func (c *Cache) RemoveRegistrants(ctx context.Context, tid string, userIDs []string, division string) error

func (*Cache) RemoveRegistrantsForTournament

func (c *Cache) RemoveRegistrantsForTournament(ctx context.Context, tid string) error

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, tm *entity.Tournament) error

Set sets a tournament in the cache, AND in the backing store. This ensures if the node crashes the tournament doesn't just vanish.

func (*Cache) SetTournamentEventChan

func (c *Cache) SetTournamentEventChan(ch chan<- *entity.EventWrapper)

SetTournamentEventChan sets the tournament event channel to the passed in channel.

func (*Cache) TournamentEventChan

func (c *Cache) TournamentEventChan() chan<- *entity.EventWrapper

func (*Cache) Unload

func (c *Cache) Unload(ctx context.Context, id string)

Unload unloads the tournament from the cache

type DBStore

type DBStore struct {
	// contains filtered or unexported fields
}

DBStore is a postgres-backed store for games.

func NewDBStore

func NewDBStore(config *config.Config, gs *game.Cache) (*DBStore, error)

NewDBStore creates a new DB store for tournament managers.

func (*DBStore) ActiveTournamentsFor

func (s *DBStore) ActiveTournamentsFor(ctx context.Context, userID string) ([][2]string, error)

ActiveTournamentsFor returns a list of 2-tuples of tournament ID, division ID that this user is registered in - only for active tournaments (ones that have not finished).

func (*DBStore) AddRegistrants

func (s *DBStore) AddRegistrants(ctx context.Context, tid string, userIDs []string, division string) error

func (*DBStore) Create

func (s *DBStore) Create(ctx context.Context, tm *entity.Tournament) error

func (*DBStore) Disconnect

func (s *DBStore) Disconnect()

func (*DBStore) Get

func (s *DBStore) Get(ctx context.Context, id string) (*entity.Tournament, error)

func (*DBStore) GetBySlug

func (s *DBStore) GetBySlug(ctx context.Context, slug string) (*entity.Tournament, error)

func (*DBStore) GetRecentClubSessions

func (s *DBStore) GetRecentClubSessions(ctx context.Context, id string, count int, offset int) (*pb.ClubSessionsResponse, error)

func (*DBStore) GetRecentGames

func (s *DBStore) GetRecentGames(ctx context.Context, tourneyID string, numGames int, offset int) (*pb.RecentGamesResponse, error)

func (*DBStore) ListAllIDs

func (s *DBStore) ListAllIDs(ctx context.Context) ([]string, error)

func (*DBStore) RemoveRegistrants

func (s *DBStore) RemoveRegistrants(ctx context.Context, tid string, userIDs []string, division string) error

func (*DBStore) RemoveRegistrantsForTournament

func (s *DBStore) RemoveRegistrantsForTournament(ctx context.Context, tid string) error

func (*DBStore) Set

func (s *DBStore) Set(ctx context.Context, tm *entity.Tournament) error

func (*DBStore) SetTournamentEventChan

func (s *DBStore) SetTournamentEventChan(c chan<- *entity.EventWrapper)

SetTournamentEventChan sets the tournament event channel to the passed in channel.

func (*DBStore) TournamentEventChan

func (s *DBStore) TournamentEventChan() chan<- *entity.EventWrapper

Jump to

Keyboard shortcuts

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