db

package
v0.0.0-...-9e256ac Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	UpdateScore(score Score) error
	ReadScores() (scores []Score, err error)
	ReadScoresByType(scoreType string) (scores []Score, err error)
	UpdateServer(server Server) error
	UpdateStatistic(statistic Statistic) error
	ReadServers() (servers []Server, err error)
	ReadServersByRegion(region string) (servers []Server, err error)
}

type DynamoDBDatabase

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

func NewDynamoDBDatabase

func NewDynamoDBDatabase(session *session.Session, stage string) (*DynamoDBDatabase, error)

func (*DynamoDBDatabase) ReadScores

func (ddb *DynamoDBDatabase) ReadScores() (scores []Score, err error)

func (*DynamoDBDatabase) ReadScoresByType

func (ddb *DynamoDBDatabase) ReadScoresByType(scoreType string) (scores []Score, err error)

func (*DynamoDBDatabase) ReadServers

func (ddb *DynamoDBDatabase) ReadServers() (servers []Server, err error)

func (*DynamoDBDatabase) ReadServersByRegion

func (ddb *DynamoDBDatabase) ReadServersByRegion(region string) (servers []Server, err error)

func (*DynamoDBDatabase) UpdateScore

func (ddb *DynamoDBDatabase) UpdateScore(score Score) error

func (*DynamoDBDatabase) UpdateServer

func (ddb *DynamoDBDatabase) UpdateServer(server Server) error

func (*DynamoDBDatabase) UpdateStatistic

func (ddb *DynamoDBDatabase) UpdateStatistic(statistic Statistic) error

type Score

type Score struct {
	Type  string `dynamo:"type"`
	Name  string `dynamo:"name"`
	Score int    `dynamo:"score"`
	TTL   int64  `dynamo:"ttl,omitempty"`
}

type Server

type Server struct {
	Region  string `dynamo:"region"`
	Slot    int    `dynamo:"slot"`
	IP      net.IP `dynamo:"ip"`
	Players int    `dynamo:"players"`
	TTL     int64  `dynamo:"ttl,omitempty"`
}

type Statistic

type Statistic struct {
	Region string `dynamo:"region"`

	// Unix millis; should be aligned to the hour
	Timestamp int64 `dynamo:"timestamp"`

	// Atomic counters
	Plays      int `dynamo:"plays"`      // i.e. each spawn
	Players    int `dynamo:"players"`    // i.e. each connection
	NewPlayers int `dynamo:"newPlayers"` // i.e. each "new" spawn
}

Jump to

Keyboard shortcuts

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