storage

package
v0.0.0-...-d479cdb Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UpdateTypeAddedGames UpdateType = "addedGamesUpdate"
	UpdateTypeAddedVotes            = "addedVotesUpdate"
	UpdateTypeResetVotes            = "resetVotesUpdate"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RoomSubscriptionMessage

type RoomSubscriptionMessage struct {
	Type   UpdateType       `json:"type"`
	Games  []bggclient.Game `json:"games"`
	Votes  []string         `json:"votes"`
	Vetoes []string         `json:"vetoes"`
	User   string           `json:"user"`
}

RoomSubscriptionMessage represents a message for when a room is updated

type Storage

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

func New

func New() (Storage, error)

New creates a new instance of Storage

func (*Storage) AddGamesToRoom

func (s *Storage) AddGamesToRoom(roomID, bggUser string, games []bggclient.Game) error

AddGamesToRoom takes a adds an hash a set of games to a hash keyed by the user

func (*Storage) GetGamesForRoom

func (s *Storage) GetGamesForRoom(roomID string) ([]bggclient.Game, error)

GetGamesForRom retrieves all of the games for a room

func (*Storage) GetUserVotes

func (s *Storage) GetUserVotes(roomID string) (VoteResult, error)

GetUserVotes returns a the vote result for a user

func (*Storage) ResetRoomVotes

func (s *Storage) ResetRoomVotes(roomID string) error

ResetRoomVotes removes all current votes for a room

func (*Storage) SetExpire

func (s *Storage) SetExpire(roomID string)

SetExpire sets the expiration for all entries related to a roomID

func (*Storage) SetUserVotes

func (s *Storage) SetUserVotes(roomID, user string, votes, vetoes []string) error

SetUserVotes sets the votes and vetoes for a user

func (*Storage) SubscribeToRoomInfo

func (s *Storage) SubscribeToRoomInfo(roomID string, watchFn func(RoomSubscriptionMessage)) func() error

SubscribeToRoomInfo sets up a subscription to updates for a room, calling the watchFn whenever an update is published

type UpdateType

type UpdateType string

UpdateType represents a specific type of update for room subscriptions

type VoteResult

type VoteResult struct {
	Votes  map[string][]string `json:"votes"`
	Vetoes map[string][]string `json:"vetoes"`
}

VoteResult represents a map of user ID to a list of games they voted for

Jump to

Keyboard shortcuts

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