datastore

package
v0.16.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB added in v0.14.0

func NewDB(n Name) (*sql.DB, func(), error)

NewDB returns an open database handle of 0 or more underlying PostgreSQL connections

Types

type Datastore

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

Datastore is a concrete implementation for a database

func NewDatastore added in v0.13.0

func NewDatastore(db *sql.DB) *Datastore

func (*Datastore) BeginTx

func (ds *Datastore) BeginTx(ctx context.Context) (*sql.Tx, error)

BeginTx is a wrapper for sql.DB.BeginTx in order to expose from the Datastore interface

func (*Datastore) CommitTx

func (ds *Datastore) CommitTx(tx *sql.Tx) error

CommitTx is a wrapper for sql.Tx.Commit in order to expose from the Datastore interface. Proper error handling is also considered.

func (*Datastore) DB added in v0.15.0

func (ds *Datastore) DB() *sql.DB

func (*Datastore) RollbackTx

func (ds *Datastore) RollbackTx(tx *sql.Tx, err error) error

RollbackTx is a wrapper for sql.Tx.Rollback in order to expose from the Datastore interface. Proper error handling is also considered.

type Datastorer added in v0.15.0

type Datastorer interface {
	DB() *sql.DB
	BeginTx(context.Context) (*sql.Tx, error)
	RollbackTx(*sql.Tx, error) error
	CommitTx(*sql.Tx) error
}

Datastorer is an interface for working with the Database

type MockDatastore

type MockDatastore struct {
}

MockDatastore is a mock implementation for a database

func NewMockDatastore added in v0.15.0

func NewMockDatastore() *MockDatastore

func (*MockDatastore) BeginTx added in v0.15.0

func (mds *MockDatastore) BeginTx(_ context.Context) (*sql.Tx, error)

BeginTx is a wrapper for sql.DB.BeginTx in order to expose from the Datastore interface

func (*MockDatastore) CommitTx added in v0.15.0

func (mds *MockDatastore) CommitTx(_ *sql.Tx) error

CommitTx is a wrapper for sql.Tx.Commit in order to expose from the Datastore interface. Proper error handling is also considered.

func (*MockDatastore) DB added in v0.16.0

func (mds *MockDatastore) DB() *sql.DB

func (*MockDatastore) RollbackTx added in v0.15.0

func (mds *MockDatastore) RollbackTx(_ *sql.Tx, err error) error

RollbackTx is a wrapper for sql.Tx.Rollback in order to expose from the Datastore interface. Proper error handling is also considered.

func (*MockDatastore) Tx added in v0.15.0

func (mds *MockDatastore) Tx() (*sql.Tx, error)

Tx exposes the Tx stored in the struct in order to be exposed from the Datastore interface.

type Name added in v0.15.0

type Name int

DSName defines the name for the Datastore

const (
	// LocalDatastore represents the local PostgreSQL db
	LocalDatastore Name = iota
	// GCPCPDatastore represents a local connection to a GCP Cloud
	// SQL db through the Google Cloud Proxy
	GCPCPDatastore
	// GCPDatastore represents a true GCP connection to a GCP
	// Cloud SQL db
	GCPDatastore
	// MockedDatastore represents a Mocked Database
	MockedDatastore
)

func (Name) String added in v0.15.0

func (n Name) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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