xgorm

package module
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 database.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() database.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.

type Driver added in v0.0.16

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

Driver is the gorm implementation for the driver name.

func NewDriver

func NewDriver(baseDriver database.Driver) (*Driver, error)

NewDriver creates a new gorm driver.

func (*Driver) CanRetry added in v0.0.16

func (d *Driver) CanRetry(err error) bool

CanRetry checks if the error relted query could be retried.

func (*Driver) DriverName added in v0.0.16

func (d *Driver) DriverName() string

DriverName gets the name of the driver.

func (*Driver) ErrorCode added in v0.0.16

func (d *Driver) ErrorCode(err error) cgerrors.ErrorCode

ErrorCode gets the error code for given error.

Jump to

Keyboard shortcuts

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