database

package
v0.0.0-...-b57609f Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FormatDatabaseName = "%sGameData" //Example NHLGameData or NBAGameData

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection interface {
	InsertGameSnapshot(ctx context.Context, snapshot interface{})
	WatchGame(ctx context.Context) (cursor Cursor, err error)
}

type Cursor

type Cursor interface {
	Close()
	Next() bool
	Decode() bson.Raw
}

type Database

type Database interface {
	Collection(collection string) Collection
}

type MongoClient

type MongoClient struct {
	*mongo.Client
}

func (*MongoClient) Database

func (m *MongoClient) Database(databaseName string) Database

Collection returns an instance of Database with provided name databaseName

func (*MongoClient) Initialize

func (m *MongoClient) Initialize(address string)

Initialize initializes the mongo client at the provided address. Uses background context

type MongoCollection

type MongoCollection struct {
	*mongo.Collection
}

func (*MongoCollection) InsertGameSnapshot

func (c *MongoCollection) InsertGameSnapshot(ctx context.Context, snapshot interface{})

InsertGameSnapshot inserts a snapshot into the collection

func (*MongoCollection) WatchGame

func (c *MongoCollection) WatchGame(ctx context.Context) (Cursor Cursor, err error)

WatchGame returns a cursor that points to a collection that will be updated when new snapshots are inserted.

type MongoCursor

type MongoCursor struct {
	mongo.Cursor
}

func (*MongoCursor) Close

func (c *MongoCursor) Close()

func (*MongoCursor) Decode

func (c *MongoCursor) Decode() bson.Raw

func (*MongoCursor) Next

func (c *MongoCursor) Next() bool

type MongoDatabase

type MongoDatabase struct {
	*mongo.Database
}

func (*MongoDatabase) Collection

func (m *MongoDatabase) Collection(collectionName string) Collection

Collection returns an instance of Collection with provided name collectionName

type Server

type Server struct {
	Client client // TODO convert this to a interface?
	// contains filtered or unexported fields
}

func CreateDatabaseServer

func CreateDatabaseServer(client client) *Server

func (*Server) GetDatabase

func (d *Server) GetDatabase(sport string) Database

Retrieve the database corresponding to a sport

func (*Server) GetDatabaseTickChannel

func (d *Server) GetDatabaseTickChannel() <-chan bool

Creates a new tick channel that replicates the database tick channel

func (*Server) WatchCollection

func (d *Server) WatchCollection(collection Collection) <-chan bson.Raw

Returns a channel for that watches a collection for new documents

Jump to

Keyboard shortcuts

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