are_hub

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

README

ACC Race Engineer hub

This is the hub application that receives data and forwards it to the appropriate connected websocket clients.

Compiling and running

Your go version must support modules in order for go build to obtain the necessary dependencies. Currently mongodb is the only supported database.

  1. Install mongodb and create a new database.
  2. cd cmd/are_hub/
  3. go build
  4. ./are_hub or ./are_hub --help to view the commandline arguments and their default values.

Deployment

Building a docker container is the easiest way (probably).

  1. docker build -t are_hub:<tag> .
  2. docker run -d -p 9001:9001 --network backend are_hub:<tag> --address :9001 --allow-origin example.com --db-user blast_hardcheese --db-pass butch_deadlift --db-host mongodb --db-name acc_race_engineer

Licence

BSD-3-clause

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoObjectsFound

func IsNoObjectsFound(e error) bool

Auxiliary function to determine whether or not an error is a NoObjectsFound error.

Types

type Archetype

type Archetype interface {
	// Should mutate the ID field to the value of the paramter.
	SetID(string)

	// Should mutate the ID field to a zero value. Eg. the empty string ("")
	UnsetID()

	// Should mutate the CreatedAt and UpdatedAt (or alternatively named) fields
	// to the current time (preferably UTC+0)
	Created()

	// Should only mutate the UpdateAt (or similar) field to the current
	// time (preferably UTC+0).
	Updated()
}

All types should implement this interface so as to be compatible with the various sub-packages.

type Channel

type Channel struct {
	Name     string `json:"name"`
	Password password
	Common   `bson:",inline"`
}

Represents a group of users listening to a data stream.

func ChannelFromCtx

func ChannelFromCtx(ctx context.Context) (*Channel, error)

Get a channel from a context.

func NewChannel

func NewChannel(name, pw string) *Channel

Create a new channel.

func (*Channel) PasswordStr

func (c *Channel) PasswordStr() string

Retrieve the channel's password as a string.

func (*Channel) SetPasswordStr

func (c *Channel) SetPasswordStr(pw string)

Mutate the channel's password to the string provided.

func (*Channel) ToCtx

func (c *Channel) ToCtx(ctx context.Context) context.Context

Insert a channel into context.

type ChannelRepo

type ChannelRepo interface {
	// Get all channels
	All(context.Context) ([]Channel, error)

	// Create a new channel
	Insert(context.Context, Archetype) error

	// Find a channel by its ID.
	FindID(context.Context, string) (*Channel, error)

	// Find and update a channel by its ID.
	UpdateID(context.Context, string, Archetype) error

	// Find and delete a channel by its ID.
	DeleteID(context.Context, string) (*Channel, error)

	// Get a count of channels.
	Count(context.Context) (int64, error)
}

type Common

type Common struct {
	ID        string    `json:"id" bson:"_id,omitempty"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Implements Archetype and is intended to be used in domain types via struct composition.

func (*Common) Created

func (c *Common) Created()

Set CreatedAt and UpdateAt to the current time (UTC+0).

func (*Common) SetID

func (c *Common) SetID(id string)

Set ID.

func (*Common) UnsetID

func (c *Common) UnsetID()

Reset ID to the empty string ("").

func (*Common) Updated

func (c *Common) Updated()

Set UpdatedAt to the current time (UTC+0).

type ContextEmbeddable

type ContextEmbeddable interface {
	ToCtx(context.Context) context.Context
}

Types implementing this interface can be stored in a context.

type NoObjectsFound

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

Returned from repositories when a query returns nothing. NoObjectsFound implements error.

func NewNoObjectsFound

func NewNoObjectsFound(r, q string) *NoObjectsFound

Create a new NoObjectsFoundError specifying the repository (eg. "users") and the query value (eg. "id == 7").

func (*NoObjectsFound) Error

func (e *NoObjectsFound) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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