database

package
v0.0.0-...-c439057 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionIsNotInitialized = errors.New("connection is not initialized")
	ErrUnsupportedDatabaseType    = errors.New("unsupported database type")
)

errors

Functions

func Wait

func Wait(ctx context.Context, db driver.Pinger, checkPeriod time.Duration)

Wait -

Types

type Database

type Database interface {
	Connect(ctx context.Context, cfg config.Database) error

	StateRepository

	driver.Pinger
	io.Closer
}

Database -

type Gorm

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

Gorm -

func NewGorm

func NewGorm() *Gorm

NewGorm -

func (*Gorm) Close

func (db *Gorm) Close() error

Close -

func (*Gorm) Connect

func (db *Gorm) Connect(ctx context.Context, cfg config.Database) error

Connect -

func (*Gorm) CreateState

func (db *Gorm) CreateState(s *State) error

CreateState -

func (*Gorm) DB

func (db *Gorm) DB() *gorm.DB

DB -

func (*Gorm) DeleteState

func (db *Gorm) DeleteState(s *State) error

DeleteState -

func (*Gorm) Ping

func (db *Gorm) Ping(ctx context.Context) error

Ping -

func (*Gorm) State

func (db *Gorm) State(indexName string) (*State, error)

State -

func (*Gorm) UpdateState

func (db *Gorm) UpdateState(s *State) error

UpdateState -

type PgGo

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

PgGo -

func NewPgGo

func NewPgGo() *PgGo

NewPgGo -

func (*PgGo) Close

func (db *PgGo) Close() error

Close -

func (*PgGo) Connect

func (db *PgGo) Connect(ctx context.Context, cfg config.Database) error

Connect -

func (*PgGo) CreateState

func (db *PgGo) CreateState(s *State) error

CreateState -

func (*PgGo) DB

func (db *PgGo) DB() *pg.DB

DB -

func (*PgGo) DeleteState

func (db *PgGo) DeleteState(s *State) error

DeleteState -

func (*PgGo) Ping

func (db *PgGo) Ping(ctx context.Context) error

Ping -

func (*PgGo) State

func (db *PgGo) State(indexName string) (*State, error)

State -

func (*PgGo) UpdateState

func (db *PgGo) UpdateState(s *State) error

UpdateState -

type State

type State struct {
	IndexName string    `gorm:"primaryKey" pg:",pk" json:"index_name"`
	IndexType string    `json:"index_type"`
	Hash      string    `json:"hash"`
	Timestamp time.Time `json:"timestamp"`
	Level     uint64    `json:"level"`
	UpdatedAt int       `gorm:"autoUpdateTime"`
	CreatedAt int       `gorm:"autoCreateTime"`
	// contains filtered or unexported fields
}

State -

func (*State) BeforeInsert

func (s *State) BeforeInsert(ctx context.Context) (context.Context, error)

BeforeInsert -

func (*State) BeforeUpdate

func (s *State) BeforeUpdate(ctx context.Context) (context.Context, error)

BeforeUpdate -

func (State) TableName

func (State) TableName() string

TableName -

type StateRepository

type StateRepository interface {
	State(name string) (*State, error)
	UpdateState(state *State) error
	CreateState(state *State) error
	DeleteState(state *State) error
}

StateRepository -

Jump to

Keyboard shortcuts

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