utils

package
v0.0.0-...-58bdd35 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverMysql     = "mysql"
	DriverNone      = ""
	RequiredVersion = 47
)
View Source
const (
	DeadlockDBErrorMessage = "Deadlock found when trying to get lock; try restarting transaction"
	TimeoutDBErrorMessage  = "Lock wait timeout exceeded; try restarting transaction"
)
View Source
const (
	KeyValueBootstrap = "bootstrap"
)

Variables

This section is empty.

Functions

func CommonAddressHexRepair

func CommonAddressHexRepair(address *common.Address) string

func ErrIsDuplicateEntryError

func ErrIsDuplicateEntryError(err error) bool

func ErrIsLockError

func ErrIsLockError(err error) bool

func ForceParseTimeParam

func ForceParseTimeParam(dsn string) (string, error)

Types

type Collector

type Collector interface {
	Error()
	Collect() error
}

func NewCollectors

func NewCollectors(collectors ...Collector) Collector

func NewCounterIncCollect

func NewCounterIncCollect(key string) Collector

func NewCounterObserveMillisCollect

func NewCounterObserveMillisCollect(key string) Collector

func NewHistogramCollect

func NewHistogramCollect(key string) Collector

func NewSuccessFailCounterAdd

func NewSuccessFailCounterAdd(keySuccess string, keyFail string, count float64) Collector

func NewSuccessFailCounterInc

func NewSuccessFailCounterInc(keySuccess string, keyFail string) Collector

type Conn

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

Conn is a wrapper around a dbr connection and a health stream

func New

func New(eventer *EventRcvr, conf cfg.DB, ro bool) (*Conn, error)

New creates a new DB for the given config

func (*Conn) Close

func (c *Conn) Close(context.Context) error

func (*Conn) NewSession

func (c *Conn) NewSession(name string, timeout time.Duration) (*dbr.Session, error)

func (*Conn) NewSessionForEventReceiver

func (c *Conn) NewSessionForEventReceiver(er dbr.EventReceiver) *dbr.Session

func (*Conn) SetConnMaxIdleTime

func (c *Conn) SetConnMaxIdleTime(d time.Duration)

func (*Conn) SetConnMaxLifetime

func (c *Conn) SetConnMaxLifetime(d time.Duration)

func (*Conn) SetMaxIdleConns

func (c *Conn) SetMaxIdleConns(n int)

func (*Conn) SetMaxOpenConns

func (c *Conn) SetMaxOpenConns(n int)

type Connections

type Connections struct {
	Eventer *EventRcvr
	// contains filtered or unexported fields
}

func NewDBFromConfig

func NewDBFromConfig(conf cfg.Services, ro bool) (*Connections, error)

func (Connections) Close

func (c Connections) Close() error

func (Connections) DB

func (c Connections) DB() *Conn

func (Connections) Stream

func (c Connections) Stream() *EventRcvr

type CounterID

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

func NewCounterID

func NewCounterID() *CounterID

func (*CounterID) Add

func (c *CounterID) Add(v string, delta int64)

func (*CounterID) Clone

func (c *CounterID) Clone() map[string]int64

func (*CounterID) Inc

func (c *CounterID) Inc(v string)

type EventRcvr

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

func (*EventRcvr) NewJob

func (e *EventRcvr) NewJob(s string) dbr.EventReceiver

func (*EventRcvr) SetLog

func (e *EventRcvr) SetLog(logger logging.Logger)

type ExecIface

type ExecIface interface {
	Exec()
}

type GenesisContainer

type GenesisContainer struct {
	NetworkID       uint32
	Time            uint64
	XChainGenesisTx *txs.Tx
	XChainID        ids.ID
	DjtxAssetID     ids.ID
	GenesisBytes    []byte
}

func NewGenesisContainer

func NewGenesisContainer(networkID uint32) (*GenesisContainer, error)

type IndexedList

type IndexedList interface {
	PushFront(key, val interface{})
	Exists(key interface{}) bool
}

func NewIndexedList

func NewIndexedList(maxSize int) IndexedList

type LCache

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

func NewTTLMap

func NewTTLMap() *LCache

func (*LCache) Get

func (m *LCache) Get(k string) ([]byte, bool)

func (*LCache) Put

func (m *LCache) Put(k string, v []byte, ttl time.Duration)

func (*LCache) Stop

func (m *LCache) Stop()

type ListenCloser

type ListenCloser interface {
	Listen() error
	Close() error
}

ListenCloser listens for messages until it's asked to close

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}
var (
	Prometheus Metrics
)

func (*Metrics) CounterAdd

func (m *Metrics) CounterAdd(name string, v float64) error

func (*Metrics) CounterInc

func (m *Metrics) CounterInc(name string) error

func (*Metrics) CounterInit

func (m *Metrics) CounterInit(name string, help string)

func (*Metrics) HistogramInit

func (m *Metrics) HistogramInit(name string, help string, buckets []float64)

func (*Metrics) HistogramObserve

func (m *Metrics) HistogramObserve(name string, v float64) error

func (*Metrics) Init

func (m *Metrics) Init()

type RetrySleeper

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

func NewRetrySleeper

func NewRetrySleeper(retries uint64, sleepDuration time.Duration, sleepDurationMax time.Duration) *RetrySleeper

func (*RetrySleeper) Inc

func (r *RetrySleeper) Inc()

type Running

type Running interface {
	Close()
	IsStopped() bool
}

func NewRunning

func NewRunning() Running

type Worker

type Worker interface {
	Enque(job interface{})
	TryEnque(job interface{})
	Finish(sleepTime time.Duration)
	JobCnt() int64
	IsFinished() bool
}

func NewWorker

func NewWorker(queueSize int, queueCnt int, processor func(int, interface{})) Worker

Jump to

Keyboard shortcuts

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