dbmw

package
v0.0.0-...-83625b3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MiddlewareDependencyDB = "*dbmw.Middleware"
)

Variables

This section is empty.

Functions

func GetConnection

func GetConnection(r *http.Request) db.DB

GetConnection returns DB from the request context.

Types

type DBConfig

type DBConfig struct {
	ConnectionString string
	SchemaVersions   map[string]int
}

func (DBConfig) SchemaVersion

func (c DBConfig) SchemaVersion(name string) int

type Middleware

type Middleware struct {
	MaxIdleConnections    int
	MaxOpenConnections    int
	ConnectionMaxLifetime time.Duration
	// contains filtered or unexported fields
}

func NewMiddleware

func NewMiddleware(s *server.Server) *Middleware

func (*Middleware) Close

func (m *Middleware) Close()

func (*Middleware) ConfigSchema

func (m *Middleware) ConfigSchema() map[string]reflect.Type

func (*Middleware) Connections

func (m *Middleware) Connections() int

func (*Middleware) Dependencies

func (m *Middleware) Dependencies() []string

func (*Middleware) Handle

func (m *Middleware) Handle(e event.Event) error

func (*Middleware) Wrap

func (m *Middleware) Wrap(next http.Handler) http.Handler

type TransactionMiddleware

type TransactionMiddleware struct {
}

TransactionMiddleware turns the DB connection in the context into a transaction.

The transaction gets committed automatically, or rolled back if an error occours.

func Begin

func Begin() *TransactionMiddleware

func (*TransactionMiddleware) Dependencies

func (t *TransactionMiddleware) Dependencies() []string

func (*TransactionMiddleware) Wrap

Jump to

Keyboard shortcuts

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