database

package
v0.0.0-...-2d12dd2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AddPeers

func AddPeers(ctx context.Context, nodeStore client.NodeStore, additionalPeers ...client.NodeInfo) error

func New

func New(ctx context.Context, datasourceName string, connPoolConfig generic.ConnectionPoolConfig, metricsRegisterer prometheus.Registerer) (server.Backend, error)

Types

type ConnectionPoolConfig

type ConnectionPoolConfig struct {
	MaxIdle     int           // zero means defaultMaxIdleConns; negative means 0
	MaxOpen     int           // <= 0 means unlimited
	MaxLifetime time.Duration // maximum amount of time a connection may be reused
}

type ErrRetry

type ErrRetry func(error) bool

type Generic

type Generic struct {
	sync.Mutex

	LockWrites            bool
	LastInsertID          bool
	DB                    *sql.DB
	GetCurrentSQL         string
	GetRevisionSQL        string
	RevisionSQL           string
	ListRevisionStartSQL  string
	GetRevisionAfterSQL   string
	CountSQL              string
	AfterSQL              string
	DeleteSQL             string
	CompactSQL            string
	UpdateCompactSQL      string
	InsertSQL             string
	FillSQL               string
	InsertLastInsertIDSQL string
	Retry                 ErrRetry
	TranslateErr          TranslateErr
}

func Open

func Open(ctx context.Context, driverName, dataSourceName string, connPoolConfig ConnectionPoolConfig, paramCharacter string, numbered bool) (*Generic, error)

func (*Generic) After

func (d *Generic) After(ctx context.Context, prefix string, rev, limit int64) (*sql.Rows, error)

func (*Generic) BeginTx

func (d *Generic) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*Generic) Compact

func (d *Generic) Compact(ctx context.Context, revision int64) (int64, error)

func (*Generic) Count

func (d *Generic) Count(ctx context.Context, prefix string) (int64, int64, error)

func (*Generic) CurrentRevision

func (d *Generic) CurrentRevision(ctx context.Context) (int64, error)

func (*Generic) DeleteRevision

func (d *Generic) DeleteRevision(ctx context.Context, revision int64) error

func (*Generic) Fill

func (d *Generic) Fill(ctx context.Context, revision int64) error

func (*Generic) GetCompactRevision

func (d *Generic) GetCompactRevision(ctx context.Context) (int64, error)

func (*Generic) GetRevision

func (d *Generic) GetRevision(ctx context.Context, revision int64) (*sql.Rows, error)

func (*Generic) Insert

func (d *Generic) Insert(ctx context.Context, key string, create, delete bool, createRevision, previousRevision int64, ttl int64, value, prevValue []byte) (id int64, err error)

func (*Generic) IsFill

func (d *Generic) IsFill(key string) bool

func (*Generic) List

func (d *Generic) List(ctx context.Context, prefix, startKey string, limit, revision int64, includeDeleted bool) (*sql.Rows, error)

func (*Generic) ListCurrent

func (d *Generic) ListCurrent(ctx context.Context, prefix string, limit int64, includeDeleted bool) (*sql.Rows, error)

func (*Generic) Migrate

func (d *Generic) Migrate(ctx context.Context)

func (*Generic) SetCompactRevision

func (d *Generic) SetCompactRevision(ctx context.Context, revision int64) error

type Stripped

type Stripped string

func (Stripped) String

func (s Stripped) String() string

type TranslateErr

type TranslateErr func(error) error

type Tx

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

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Compact

func (t *Tx) Compact(ctx context.Context, revision int64) (int64, error)

func (*Tx) CurrentRevision

func (t *Tx) CurrentRevision(ctx context.Context) (int64, error)

func (*Tx) DeleteRevision

func (t *Tx) DeleteRevision(ctx context.Context, revision int64) error

func (*Tx) GetCompactRevision

func (t *Tx) GetCompactRevision(ctx context.Context) (int64, error)

func (*Tx) GetRevision

func (t *Tx) GetRevision(ctx context.Context, revision int64) (*sql.Rows, error)

func (*Tx) MustCommit

func (t *Tx) MustCommit()

func (*Tx) MustRollback

func (t *Tx) MustRollback()

func (*Tx) Rollback

func (t *Tx) Rollback() error

func (*Tx) SetCompactRevision

func (t *Tx) SetCompactRevision(ctx context.Context, revision int64) error

Jump to

Keyboard shortcuts

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