utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: BSD-3-Clause Imports: 35 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 DateFormat added in v1.0.0

func DateFormat(startTime time.Time, endTime time.Time, columnName string) string

func ErrIsDuplicateEntryError

func ErrIsDuplicateEntryError(err error) bool

func ErrIsLockError

func ErrIsLockError(err error) bool

func ForceParseTimeParam

func ForceParseTimeParam(dsn string) (string, error)

func GetCountryEmissions added in v0.4.6

func GetCountryEmissions(startDate time.Time, endDate time.Time, config cfg.EndpointService, rpc string) (models.Emissions, error)

func GetDailyEmissions added in v0.4.6

func GetDailyEmissions(startDate time.Time, endDate time.Time, config cfg.EndpointService, rpc string) models.Emissions

func GetDate added in v0.4.6

func GetDate(unixTime uint64) (string, error)

func GetLocationByIP added in v0.4.6

func GetLocationByIP(ctx context.Context, ip string, config *cfg.EndpointService) (models.IPAPIResponse, error)

func GetNetworkEmissions added in v0.4.6

func GetNetworkEmissions(startDate time.Time, endDate time.Time, config cfg.EndpointService, rpc string) (*models.Emissions, error)

func GetNetworkEmissionsPerTransaction added in v0.4.6

func GetNetworkEmissionsPerTransaction(startDate time.Time, endDate time.Time, config cfg.EndpointService, rpc string) (*models.Emissions, error)

func GetSizeFromStringtoFloat added in v0.4.6

func GetSizeFromStringtoFloat(size string) float64

func GetValidatorsGeoIPInfo added in v0.4.6

func GetValidatorsGeoIPInfo(rpc string, geoIPConfig *cfg.EndpointService, log logging.Logger) (models.GeoIPValidators, error)

func PeerIndex added in v0.4.6

func PeerIndex(peers []info.Peer, nodeID ids.NodeID) int

func UnionStatistics added in v0.4.6

func UnionStatistics(
	cvmLatestTx []*models.CvmStatisticsCache,
	cvmLatestBlocks []*models.CvmBlocksStatisticsCache,
	avmLatestTx []*models.AvmStatisticsCache,
	addressesFrom []*models.AddressesCache,
	addressesTo []*models.AddressesCache,
) []models.StatisticsCache

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
	AvaxAssetID     ids.ID
	GenesisBytes    []byte
	Genesis         *platformGenesis.Genesis
}

func NewGenesisContainer

func NewGenesisContainer(cfg *cfg.Config) (*GenesisContainer, error)

func NewInternalGenesisContainer added in v0.4.0

func NewInternalGenesisContainer(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