shared

package
v0.0.0-...-9022a88 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomB32String

func GenerateRandomB32String(length int) (string, error)

GenerateRandomB32String returns a base32-encoded string of `length` random bytes.

func GenerateRandomBytes

func GenerateRandomBytes(length int) ([]byte, error)

GenerateRandomBytes returns an array of `length` random bytes.

func GetEnv

func GetEnv(key string, def string) string

GetEnv returns an OS environment variable with a safety fallback.

func InitLogging

func InitLogging()

InitLogging configures global logging parameters.

func LoadConfigFromPath

func LoadConfigFromPath(path string, config interface{}) interface{}

LoadConfigFromPath loads an arbitrary object from JSON data specified by the given path.

func WaitForSigIntAndQuit

func WaitForSigIntAndQuit()

WaitForSigIntAndQuit blocks until a SIGINT is received and then exits the program.

Types

type GameDefinition

type GameDefinition struct {
	GameID     GameIDType `json:"gameId"`
	HostPolicy HostPolicy `json:"hostPolicy"`
}

GameDefinition defines a specific game supported by a hotel server cluster, identified by a game ID, along with policies on how the game is managed.

type GameIDType

type GameIDType string

GameIDType is a unique ID for a game type, so hotel can multiplex across games.

type HostPolicy

type HostPolicy int

HostPolicy determines how the game is allowed to be hosted/started by clients.

const (
	// HostPolicy_DISABLED means new servers may not be hosted or spawned by regular clients.
	// They can only be hosted by privileged clients (server owners).
	HostPolicy_DISABLED HostPolicy = iota

	// HostPolicy_CLIENTS_ONLY means new servers can be hosted and registered by any client,
	// but clients cannot request new instances to be spawned.
	HostPolicy_CLIENTS_ONLY

	// HostPolicy_SPAWN_ONLY means new servers can be spawn requested, but arbitrary servers
	// cannot be hosted/registered.
	HostPolicy_SPAWN_ONLY

	// HostPolicy_ANY means new servers can be hosted by any client as well as requested to be spawned.
	HostPolicy_ANY
)

func (*HostPolicy) UnmarshalJSON

func (hp *HostPolicy) UnmarshalJSON(data []byte) error

UnmarshalJSON fills the instance from JSON data.

type SerializableDuration

type SerializableDuration struct {
	time.Duration
}

SerializableDuration is a Duration type which can be serialized to/from JSON.

func (*SerializableDuration) UnmarshalJSON

func (sd *SerializableDuration) UnmarshalJSON(data []byte) error

UnmarshalJSON fills the instance from JSON data.

Jump to

Keyboard shortcuts

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