middleware

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package middleware provides hooks that are called when executing sql queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, queryName string) context.Context

NewContext returns a SQL middleware context with the query name embedded in it for downstream middleware. All contexts passed into the SQL middleware chain must have first called this function

Types

type Middleware

type Middleware []MiddlewareStart

Middleware aliases a list of SQL Middleware

func (Middleware) After

func (m Middleware) After(ctx context.Context, query string, args ...interface{}) (context.Context, error)

After satisfies the sqlhooks interface for hooks called after the query has completed

func (Middleware) Before

func (m Middleware) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error)

Before satisfies the sqlhooks interface for hooks called before the query is executed

func (Middleware) OnError

func (m Middleware) OnError(ctx context.Context, queryErr error, query string, args ...interface{}) error

OnError satisfies the sqlhooks interface for hooks called when a query errors

type MiddlewareEnd

type MiddlewareEnd func(ctx context.Context, queryName, query string, queryErr error, args ...interface{}) (context.Context, error)

MiddlewareEnd is called after the SQL query has completed

type MiddlewareStart

type MiddlewareStart func(ctx context.Context, queryName, query string, args ...interface{}) (context.Context, MiddlewareEnd, error)

MiddlewareStart is called before the SQL query has started

Jump to

Keyboard shortcuts

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