mongo

package
v0.0.0-...-660a5ed Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoURI           error = errors.New("no URI provided -- supply an environment variable containing the mongodb URI, or set it in the MONGODB_URI environment variable")
	ErrMissingUser     error = errors.New("unset Mongo user variable: please export the MONGO_USER variable")
	ErrMissingPassword error = errors.New("unset Mongo password variable: please export the MONGO_PASSWORD variable")
	ErrMissingDatabase error = errors.New("unset Mongo database variable: please export the MONGO_DATABASE variable")
)

Functions

func New

func New(address, database, collection string) (io.WriteCloser, error)

New function will take in a MongoDB address, database and collection names; and create a new instance of a Mongo object; returning an io.WriteCloser and an error.

func WithMongo

func WithMongo(addr, database, collection string) log.LoggerConfig

WithMongo function takes in the address to the mongo server, and a database and collection name; and returns a LoggerConfig so that this type of writer is defined in a Logger

Types

type Mongo

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

Mongo struct is a wrapper for a MongoDB database to be used as a Log Writer

func (*Mongo) Close

func (d *Mongo) Close() error

Close method is used to terminate the live connection to the MongoDB instance.

func (*Mongo) Create

func (d *Mongo) Create(msg ...*event.Event) error

Create method will register any number of event.Event in the Postgres database, returning an error

func (*Mongo) Write

func (d *Mongo) Write(p []byte) (n int, err error)

Write method implements the io.Writer interface, for Postgres DBs to be used with Logger, as its writer.

The input message is expected to be a protobuf-marshalled event.Event, which is decoded

Jump to

Keyboard shortcuts

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