Documentation ¶
Index ¶
- Constants
- Variables
- func MigrateGameDocument(cfg *config.Config, gdoc *ipc.GameDocument) error
- type BroadcastGame
- type DBStore
- func (s *DBStore) CreateAnnotatedGame(ctx context.Context, creatorUUID string, gameUUID string, private bool, ...) error
- func (s *DBStore) DeleteAnnotatedGame(ctx context.Context, uuid string) error
- func (s *DBStore) Disconnect()
- func (s *DBStore) GameIsDone(ctx context.Context, gid string) (bool, error)
- func (s *DBStore) GameOwnedBy(ctx context.Context, gid, uid string) (bool, error)
- func (s *DBStore) GamesForEditor(ctx context.Context, editorID string, unfinished bool, limit, offset int) ([]*BroadcastGame, error)
- func (s *DBStore) MarkAnnotatedGameDone(ctx context.Context, uuid string) error
- func (s *DBStore) OutstandingGames(ctx context.Context, creatorUUID string) ([]*BroadcastGame, error)
- func (s *DBStore) UpdateAnnotatedGameQuickdata(ctx context.Context, uuid string, quickdata *entity.Quickdata) error
- type GameDocumentStore
- func (gs *GameDocumentStore) DeleteDocument(ctx context.Context, uuid string) error
- func (gs *GameDocumentStore) DisconnectRDB()
- func (gs *GameDocumentStore) GetDocument(ctx context.Context, uuid string, lock bool) (*MaybeLockedDocument, error)
- func (gs *GameDocumentStore) SetDocument(ctx context.Context, gdoc *ipc.GameDocument) error
- func (gs *GameDocumentStore) UnlockDocument(ctx context.Context, doc *MaybeLockedDocument) error
- func (gs *GameDocumentStore) UpdateDocument(ctx context.Context, doc *MaybeLockedDocument) error
- type MaybeLockedDocument
Constants ¶
const CurrentGameDocumentVersion = 2
const MaxExpirationSeconds = 10 * 24 * 60 * 60 // 10 days
const RedisDocPrefix = "gdoc:"
const RedisExpirationSeconds = 15 * 60 // 15 minutes
const RedisMutexPrefix = "gdocmutex:"
Variables ¶
var ErrDoesNotExist = errors.New("does not exist")
Functions ¶
func MigrateGameDocument ¶
func MigrateGameDocument(cfg *config.Config, gdoc *ipc.GameDocument) error
MigrateGameDocument performs an in-place migration of a GameDocument. It does not save it back to any store. This is meant to be used as a temporary function; we should migrate the database permanently after having this in production for a bit while people are on old versions.
Types ¶
type BroadcastGame ¶
type DBStore ¶
type DBStore struct {
// contains filtered or unexported fields
}
func (*DBStore) CreateAnnotatedGame ¶
func (*DBStore) DeleteAnnotatedGame ¶
func (*DBStore) Disconnect ¶
func (s *DBStore) Disconnect()
func (*DBStore) GameIsDone ¶
func (*DBStore) GameOwnedBy ¶
func (*DBStore) GamesForEditor ¶
func (*DBStore) MarkAnnotatedGameDone ¶
func (*DBStore) OutstandingGames ¶
func (s *DBStore) OutstandingGames(ctx context.Context, creatorUUID string) ([]*BroadcastGame, error)
OutstandingGames returns a list of game IDs for games that are not yet done being annotated. The system will only allow a certain number of games to remain undone for an annotator.
type GameDocumentStore ¶
type GameDocumentStore struct {
// contains filtered or unexported fields
}
func NewGameDocumentStore ¶
func (*GameDocumentStore) DeleteDocument ¶
func (gs *GameDocumentStore) DeleteDocument(ctx context.Context, uuid string) error
func (*GameDocumentStore) DisconnectRDB ¶
func (gs *GameDocumentStore) DisconnectRDB()
func (*GameDocumentStore) GetDocument ¶
func (gs *GameDocumentStore) GetDocument(ctx context.Context, uuid string, lock bool) (*MaybeLockedDocument, error)
GetDocument gets a game document from the store. It tries Redis first, then S3 if not found in Redis. The lock parameter is ignored if this item is not in Redis. If it is in Redis, and lock is true, the document is locked. The SetDocument function will try to unlock it. If it locked, we return the lock value for future usage.
func (*GameDocumentStore) SetDocument ¶
func (gs *GameDocumentStore) SetDocument(ctx context.Context, gdoc *ipc.GameDocument) error
SetDocument should be called to set the initial document in redis.
func (*GameDocumentStore) UnlockDocument ¶
func (gs *GameDocumentStore) UnlockDocument(ctx context.Context, doc *MaybeLockedDocument) error
func (*GameDocumentStore) UpdateDocument ¶
func (gs *GameDocumentStore) UpdateDocument(ctx context.Context, doc *MaybeLockedDocument) error
UpdateDocument makes an atomic update to document in the Redis store. If the game is done, though, it will write it to S3 and expire it from the Redis store.
type MaybeLockedDocument ¶
type MaybeLockedDocument struct { *ipc.GameDocument LockValue string }
MaybeLockedDocument wraps a game document but also contains a value. If the value is not blank then the document is locked.