Documentation ¶
Index ¶
- Constants
- func WithAuthentication(next http.Handler) http.Handler
- func WithBuildingQueueItemIDContext(next http.Handler) http.Handler
- func WithCityIDContext(next http.Handler) http.Handler
- func WithMovementIDContext(next http.Handler) http.Handler
- func WithPagination(next http.Handler) http.Handler
- func WithUnitQueueItemIDContext(next http.Handler) http.Handler
- type ContextKey
- type EventSourcer
- type PathParameterKey
- type QueryParameterKey
- type ServerHandler
- func (s *ServerHandler) CreateCity(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) DeleteCity(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) GetBuildingQueueItem(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) GetCity(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) GetCityInfo(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) GetMovement(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) GetUnitQueueItem(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) GetWelcome(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) ListBuildingQueueItems(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) ListCityInfo(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) ListMovements(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) ListUnitQueueItem(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) QueueBuilding(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) QueueUnit(w http.ResponseWriter, r *http.Request)
- func (s *ServerHandler) StartMovement(w http.ResponseWriter, r *http.Request)
- type StickerioRepository
- func (r *StickerioRepository) DeleteBuildingQueueItem(ctx context.Context, buildingQueueItemID string) error
- func (r *StickerioRepository) DeleteBuildingQueueItemsFromCity(ctx context.Context, cityID string) error
- func (r *StickerioRepository) DeleteCity(ctx context.Context, cityID string) error
- func (r *StickerioRepository) DeleteMovement(ctx context.Context, movementID string) error
- func (r *StickerioRepository) DeleteUnitQueueItem(ctx context.Context, unitQueueItemID string) error
- func (r *StickerioRepository) DeleteUnitQueueItemsFromCity(ctx context.Context, cityID string) error
- func (r *StickerioRepository) GetBuildingQueueItem(ctx context.Context, id, cityID, playerID string) (*dbBuildingQueueItem, error)
- func (r *StickerioRepository) GetCity(ctx context.Context, id, playerID string) (*dbCity, error)
- func (r *StickerioRepository) GetCityInfo(ctx context.Context, id string) (*dbCity, error)
- func (r *StickerioRepository) GetMovement(ctx context.Context, id, playerID string) (*dbMovement, error)
- func (r *StickerioRepository) GetUnitQueueItem(ctx context.Context, id, cityID, playerID string) (*dbUnitQueueItem, error)
- func (r *StickerioRepository) InsertEvent(ctx context.Context, e *event) error
- func (r *StickerioRepository) ListBuildingQueueItems(ctx context.Context, cityID, playerID, lastID string, pageSize int) ([]*dbBuildingQueueItem, error)
- func (r *StickerioRepository) ListCityInfo(ctx context.Context, lastID string, pageSize int, ...) ([]*dbCity, error)
- func (r *StickerioRepository) ListEvents(ctx context.Context, untilEpoch int64) ([]*event, error)
- func (r *StickerioRepository) ListMovements(ctx context.Context, playerID, lastID string, pageSize int, ...) ([]*dbMovement, error)
- func (r *StickerioRepository) ListUnitQueueItems(ctx context.Context, cityID, playerID, lastID string, pageSize int) ([]*dbUnitQueueItem, error)
- func (r *StickerioRepository) UpsertBuildingQueueItem(ctx context.Context, m *dbBuildingQueueItem) error
- func (r *StickerioRepository) UpsertCity(ctx context.Context, c *dbCity) error
- func (r *StickerioRepository) UpsertMovement(ctx context.Context, m *dbMovement) error
- func (r *StickerioRepository) UpsertUnitQueueItem(ctx context.Context, m *dbUnitQueueItem) error
Constants ¶
View Source
const ( APIVersion = "v1" AuthenticationHeaderKey = "Authentication" CityID PathParameterKey = "cityid" ItemID PathParameterKey = "itemid" MovementID PathParameterKey = "movementid" LastID QueryParameterKey = "lastid" PageSize QueryParameterKey = "pagesize" PlayerID QueryParameterKey = "playerid" LocationBounds QueryParameterKey = "locationbounds" OriginID QueryParameterKey = "originid" DestinationID QueryParameterKey = "destinationid" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextKey ¶
type ContextKey string
const ( PlayerIDKey ContextKey = "playerID" CityIDKey ContextKey = "cityID" MovementIDKey ContextKey = "movementID" UnitQueueItemIDKey ContextKey = "unitQueueItemID" BuildingQueueItemIDKey ContextKey = "buildingQueueItemID" LastIDKey ContextKey = "lastID" PageSizeKey ContextKey = "pageSize" )
func (ContextKey) String ¶
func (s ContextKey) String() string
type EventSourcer ¶
type EventSourcer struct {
// contains filtered or unexported fields
}
The EventSourcer is the magic of this game. It will hold an in-memory state of the game for quick calculations and ordered event processing, but will trigger re-sync periods when the whole event log is re-processed to ensure the consistent state. The in memory state will hold:
- a map of city IDs to full city descriptions
- a map of movement IDs to full movement descriptions
- a map of city IDs to a map of unit queue itmes
- a map of city IDs to a map of building queue itmes
Any of the event processors will do:
- event payload parsing
- event content validation and re-calculation of current state
- chain event creation
- upsert on cached view tables
After all events are processed, the actual view tables are updated. Chain events are only processed on re-sync: make it so that re-sync happens often enough.
func NewEventSourcer ¶
func NewEventSourcer(repository eventsRepository) *EventSourcer
func (*EventSourcer) StartEventsWorker ¶
func (s *EventSourcer) StartEventsWorker(ctx context.Context, resyncPeriod time.Duration)
type PathParameterKey ¶
type PathParameterKey string
func (PathParameterKey) String ¶
func (s PathParameterKey) String() string
type QueryParameterKey ¶
type QueryParameterKey string
func (QueryParameterKey) String ¶
func (s QueryParameterKey) String() string
type ServerHandler ¶
type ServerHandler struct {
// contains filtered or unexported fields
}
func NewServerHandler ¶
func NewServerHandler(repository *StickerioRepository, eventSourcer eventSourcer) *ServerHandler
func (*ServerHandler) CreateCity ¶
func (s *ServerHandler) CreateCity(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) DeleteCity ¶
func (s *ServerHandler) DeleteCity(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) GetBuildingQueueItem ¶
func (s *ServerHandler) GetBuildingQueueItem(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) GetCity ¶
func (s *ServerHandler) GetCity(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) GetCityInfo ¶
func (s *ServerHandler) GetCityInfo(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) GetMovement ¶
func (s *ServerHandler) GetMovement(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) GetUnitQueueItem ¶
func (s *ServerHandler) GetUnitQueueItem(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) GetWelcome ¶
func (s *ServerHandler) GetWelcome(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) ListBuildingQueueItems ¶
func (s *ServerHandler) ListBuildingQueueItems(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) ListCityInfo ¶
func (s *ServerHandler) ListCityInfo(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) ListMovements ¶
func (s *ServerHandler) ListMovements(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) ListUnitQueueItem ¶
func (s *ServerHandler) ListUnitQueueItem(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) QueueBuilding ¶
func (s *ServerHandler) QueueBuilding(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) QueueUnit ¶
func (s *ServerHandler) QueueUnit(w http.ResponseWriter, r *http.Request)
func (*ServerHandler) StartMovement ¶
func (s *ServerHandler) StartMovement(w http.ResponseWriter, r *http.Request)
type StickerioRepository ¶
type StickerioRepository struct {
// contains filtered or unexported fields
}
func NewStickerioRepository ¶
func NewStickerioRepository(dataSourceName string) *StickerioRepository
func (*StickerioRepository) DeleteBuildingQueueItem ¶
func (r *StickerioRepository) DeleteBuildingQueueItem(ctx context.Context, buildingQueueItemID string) error
func (*StickerioRepository) DeleteBuildingQueueItemsFromCity ¶
func (r *StickerioRepository) DeleteBuildingQueueItemsFromCity(ctx context.Context, cityID string) error
func (*StickerioRepository) DeleteCity ¶
func (r *StickerioRepository) DeleteCity(ctx context.Context, cityID string) error
func (*StickerioRepository) DeleteMovement ¶
func (r *StickerioRepository) DeleteMovement(ctx context.Context, movementID string) error
func (*StickerioRepository) DeleteUnitQueueItem ¶
func (r *StickerioRepository) DeleteUnitQueueItem(ctx context.Context, unitQueueItemID string) error
func (*StickerioRepository) DeleteUnitQueueItemsFromCity ¶
func (r *StickerioRepository) DeleteUnitQueueItemsFromCity(ctx context.Context, cityID string) error
func (*StickerioRepository) GetBuildingQueueItem ¶
func (r *StickerioRepository) GetBuildingQueueItem(ctx context.Context, id, cityID, playerID string) (*dbBuildingQueueItem, error)
func (*StickerioRepository) GetCity ¶
func (r *StickerioRepository) GetCity(ctx context.Context, id, playerID string) (*dbCity, error)
func (*StickerioRepository) GetCityInfo ¶
func (r *StickerioRepository) GetCityInfo(ctx context.Context, id string) (*dbCity, error)
func (*StickerioRepository) GetMovement ¶
func (r *StickerioRepository) GetMovement(ctx context.Context, id, playerID string) (*dbMovement, error)
func (*StickerioRepository) GetUnitQueueItem ¶
func (r *StickerioRepository) GetUnitQueueItem(ctx context.Context, id, cityID, playerID string) (*dbUnitQueueItem, error)
func (*StickerioRepository) InsertEvent ¶
func (r *StickerioRepository) InsertEvent(ctx context.Context, e *event) error
func (*StickerioRepository) ListBuildingQueueItems ¶
func (*StickerioRepository) ListCityInfo ¶
func (*StickerioRepository) ListEvents ¶
func (r *StickerioRepository) ListEvents(ctx context.Context, untilEpoch int64) ([]*event, error)
func (*StickerioRepository) ListMovements ¶
func (*StickerioRepository) ListUnitQueueItems ¶
func (*StickerioRepository) UpsertBuildingQueueItem ¶
func (r *StickerioRepository) UpsertBuildingQueueItem(ctx context.Context, m *dbBuildingQueueItem) error
func (*StickerioRepository) UpsertCity ¶
func (r *StickerioRepository) UpsertCity(ctx context.Context, c *dbCity) error
func (*StickerioRepository) UpsertMovement ¶
func (r *StickerioRepository) UpsertMovement(ctx context.Context, m *dbMovement) error
func (*StickerioRepository) UpsertUnitQueueItem ¶
func (r *StickerioRepository) UpsertUnitQueueItem(ctx context.Context, m *dbUnitQueueItem) error
Click to show internal directories.
Click to hide internal directories.