postgres

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoEnv           error = errors.New("no env variable provided -- ensure that the environment variables for POSTGRES_USER and POSTGRES_PASSWORD are set")
	ErrMissingUser     error = errors.New("unset Postgres user variable: please export the POSTGRES_USER variable")
	ErrMissingPassword error = errors.New("unset Postgres password variable: please export the POSTGRES_PASSWORD variable")
	ErrMissingDatabase error = errors.New("unset Postgres database variable: please export the POSTGRES_DATABASE variable")
)

Functions

func New

func New(address, port, database string) (sqldb io.WriteCloser, err error)

New function will take in a postgres DB address, port and database name; and create a new instance of a Postgres object; returning an io.WriteCloser and an error.

func WithPostgres

func WithPostgres(addr, port, database string) log.LoggerConfig

WithPostgres function takes in an address and port to a Postgres server, and a database name; and returns a LoggerConfig so that this type of writer is defined in a Logger

Types

type Postgres

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

func (*Postgres) Close

func (d *Postgres) Close() error

Close method is implemented for compatibility with the Database interface.

While this ORM doesn't force users to close the connection, MongoDB does, and the method should be available for use

func (*Postgres) Create

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

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

func (*Postgres) Write

func (s *Postgres) 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