db

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package db handles interactions with the MongoDB instance and works as an abstraction layer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PGTimestamp added in v0.0.2

func PGTimestamp(t time.Time) pgtype.Timestamp

func PGUint64 added in v0.0.2

func PGUint64(x uint64) pgtype.Numeric

Types

type Assignment added in v0.0.2

type Assignment struct {
	gen.Assignment
	Tasks []gen.AssignmentTask
}

Assignment implements EntityMerger

func (*Assignment) Merge added in v0.0.2

func (a *Assignment) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

type Campaign added in v0.0.2

type Campaign gen.Campaign

Campaign implements EntityMerger

func (*Campaign) Merge added in v0.0.2

func (c *Campaign) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

Merge implements EntityMerger. It is assumed that the currently known planets are already present in the database.

type Client

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

Client is the abstraction layer for the MongoDB connector

func New

func New(cfg *config.Config, logger *log.Logger) (*Client, error)

New creates a new client and connects it to the DB

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect disconnects from the MongoDB instance

func (*Client) Merge added in v0.0.2

func (c *Client) Merge(ctx context.Context, mergers ...[]EntityMerger) (err error)

func (*Client) MigrateUp

func (c *Client) MigrateUp(migrationsFolder string) error

MigrateUp runs required migrations to get to the latest version.

This should be run before any other operations.

type Dispatch added in v0.0.2

type Dispatch gen.Dispatch

Dispatch implements EntityMerger

func (*Dispatch) Merge added in v0.0.2

func (d *Dispatch) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

type EntityMerger added in v0.0.2

type EntityMerger interface {
	Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error
}

type Event added in v0.0.2

type Event gen.Event

Event implements EntityMerger

func (*Event) Merge added in v0.0.2

func (e *Event) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

type Planet added in v0.0.2

type Planet struct {
	gen.Planet
	Biome   gen.Biome
	Hazards []gen.Hazard
}

Planet implements EntityMerger

func (*Planet) Merge added in v0.0.2

func (p *Planet) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

type PlanetSnapshot added in v0.0.2

type PlanetSnapshot struct {
	gen.PlanetSnapshot
	Event      *gen.EventSnapshot
	Statistics gen.SnapshotStatistic
}

type Snapshot added in v0.0.2

type Snapshot struct {
	gen.Snapshot
	WarSnapshot         gen.WarSnapshot
	AssignmentSnapshots []gen.AssignmentSnapshot
	PlanetSnapshots     []PlanetSnapshot
	Statistics          gen.SnapshotStatistic
}

Snapshot implements EntityMerger

func (*Snapshot) Merge added in v0.0.2

func (s *Snapshot) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

type War added in v0.0.2

type War gen.War

War implements EntityMerger

func (*War) Merge added in v0.0.2

func (w *War) Merge(ctx context.Context, tx *gen.Queries, stats tableMergeStats) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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