hooks

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCanRetry = errors.New("connection reconnect")

Functions

This section is empty.

Types

type Code

type Code int
const (
	DatabaseError Code = 2020
	BadConnection Code = 2021
	Reconnected   Code = 2022
)

func (Code) GRPC

func (c Code) GRPC() int

func (Code) HTTP

func (c Code) HTTP() int

func (Code) Int

func (c Code) Int() int

type Config

type Config struct {
	ReconnectFn func() error

	Addr           string
	User           string
	Database       string
	CertPath       string
	Type           string
	ReadTimeout    string
	WriteTimeout   string
	DataSourceName string
	DriverName     string
	Instance       string
}

Config is internal hook config with specified information.

type MetricCollector added in v0.5.0

type MetricCollector interface {
	SerializationFailureInc(dbType, dbAddr, dbName string)
	QueryDurationObserve(dbType, dbAddr, dbName, operation, table string, isError bool, since time.Duration)
}

type MetricsHook added in v0.5.0

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

func NewMetricsHook added in v0.5.0

func NewMetricsHook(config *Config, collector MetricCollector) *MetricsHook

func (*MetricsHook) After added in v0.5.0

func (h *MetricsHook) After(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

func (*MetricsHook) Before added in v0.5.0

func (h *MetricsHook) Before(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

func (*MetricsHook) Error added in v0.5.0

func (h *MetricsHook) Error(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

type ReconnectHook

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

func NewReconnectHook

func NewReconnectHook(config *Config) *ReconnectHook

func (*ReconnectHook) Error

func (rh *ReconnectHook) Error(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

type SimplerrHook

type SimplerrHook struct{}

func NewSimplerrHook

func NewSimplerrHook() *SimplerrHook

func (*SimplerrHook) Error

func (h *SimplerrHook) Error(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

type TracingHook

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

func NewTracingHook

func NewTracingHook(tracer trace.Tracer, config *Config) *TracingHook

func (*TracingHook) After

func (hook *TracingHook) After(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

func (*TracingHook) Before

func (hook *TracingHook) Before(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

func (*TracingHook) Error

func (hook *TracingHook) Error(ctx context.Context, input *dbhook.HookInput) (context.Context, error)

Jump to

Keyboard shortcuts

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