xgorm

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDriver

func NewDriver(baseDriver xservice.Driver) (xservice.Driver, error)

NewDriver creates a new gorm driver.

Types

type Adapter

type Adapter struct {
	DB         *gorm.DB
	RetryCount int
	// contains filtered or unexported fields
}

Adapter is the gorm structure used as a template for the gorm based adapters.

func NewAdapter

func NewAdapter(db *gorm.DB, drv xservice.Driver, retryCount int) (*Adapter, error)

NewAdapter creates a new gorm based adapter. If the input driver is not a GORM driver, it would be wrapped by the xgorm.driver.

func (*Adapter) Do

func (g *Adapter) Do(ctx context.Context, db *gorm.DB, f func(ctx context.Context, db *gorm.DB) error) error

Do executes given function 'f' so that if there would be a connection error it would try to retry the query up to the limit set on initialization.

func (*Adapter) Driver

func (g *Adapter) Driver() xservice.Driver

Driver gets the adapter driver.

func (*Adapter) Err

func (g *Adapter) Err(err error) error

Err parses err using adapter driver.

func (*Adapter) Health

func (g *Adapter) Health(ctx context.Context) error

Health implements health check for the service.

Jump to

Keyboard shortcuts

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