sqlstore

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SQLMigrationsDir        = "migrations"
	GooseDBVersionTableName = config.MonitoringDbSchema + ".metrics_goose_db_version"
)
View Source
const (
	RetentionPolicyArchival = "archival"
	RetentionPolicyStandard = "standard"
	RetentionPolicyLite     = "lite"
)
View Source
const DefaultUpsertTxTimeout = 30 * time.Second
View Source
const InfiniteInterval = "inf"

Variables

View Source
var (
	ErrAcquireTx    = errors.New("failed to acquire transaction")
	ErrUpsertSingle = errors.New("failed to upsert single row")
	ErrUpsertCommit = errors.New("failed to commit the upsert transaction")
)
View Source
var ArchivalRetentionPolicy = RetentionPolicies{
	{
		TableName: "metrics.block_signers",
		Interval:  InfiniteInterval,
	},
	{
		TableName: "metrics.network_history_segments",
		Interval:  InfiniteInterval,
	},
	{
		TableName: "metrics.comet_txs",
		Interval:  InfiniteInterval,
	},
	{
		TableName: "metrics.network_balances",
		Interval:  InfiniteInterval,
	},
	{
		TableName: "metrics.asset_prices",
		Interval:  InfiniteInterval,
	},
	{
		TableName: "metrics.monitoring_status",
		Interval:  InfiniteInterval,
	},
}
View Source
var EmbedMigrations embed.FS
View Source
var LiteRetentionPolicy = RetentionPolicies{
	RetentionPolicy{
		TableName: "metrics.block_signers",
		Interval:  "7 days",
	},
	RetentionPolicy{
		TableName: "metrics.network_history_segments",
		Interval:  "7 days",
	},
	RetentionPolicy{
		TableName: "metrics.comet_txs",
		Interval:  "7 days",
	},
	RetentionPolicy{
		TableName: "metrics.network_balances",
		Interval:  "7 days",
	},
	RetentionPolicy{
		TableName: "metrics.asset_prices",
		Interval:  "7 days",
	},
	RetentionPolicy{
		TableName: "metrics.monitoring_status",
		Interval:  "7 days",
	},
}
View Source
var StandardRetentionPolicy = RetentionPolicies{
	RetentionPolicy{
		TableName: "metrics.block_signers",
		Interval:  "4 months",
	},
	RetentionPolicy{
		TableName: "metrics.network_history_segments",
		Interval:  "4 months",
	},
	RetentionPolicy{
		TableName: "metrics.comet_txs",
		Interval:  "4 months",
	},
	RetentionPolicy{
		TableName: "metrics.network_balances",
		Interval:  "4 months",
	},
	RetentionPolicy{
		TableName: "metrics.asset_prices",
		Interval:  "4 months",
	},
	RetentionPolicy{
		TableName: "metrics.monitoring_status",
		Interval:  "7 days",
	},
}

Functions

func DBFromConnectionConfig added in v0.9.0

func DBFromConnectionConfig(
	log *logging.Logger,
	connConfig vega_sqlstore.ConnectionConfig,
) (*sql.DB, error)

func MigrateToLatestSchema

func MigrateToLatestSchema(log *logging.Logger, connConfig vega_sqlstore.ConnectionConfig) error

func NewTransactionalConnectionSource

func NewTransactionalConnectionSource(log *logging.Logger, connConfig vega_sqlstore.ConnectionConfig) (*vega_sqlstore.ConnectionSource, error)

func NewUpsertErr added in v0.9.0

func NewUpsertErr(store StoreType, baseError, actualError error) error

func PrepareListForInCondition added in v0.11.0

func PrepareListForInCondition[T string | []byte](input []T) string

func RevertOneVersion

func RevertOneVersion(log *logging.Logger, connConfig vega_sqlstore.ConnectionConfig) error

func RevertToSchemaVersionZero

func RevertToSchemaVersionZero(
	log *logging.Logger,
	connConfig vega_sqlstore.ConnectionConfig,
) error

func SetRetentionPolicies added in v0.9.0

func SetRetentionPolicies(connConfig vega_sqlstore.ConnectionConfig, basePolicy string, policyOverrides []config.RetentionPolicy, logger *logging.Logger) error

Types

type AssetPrices

type AssetPrices struct {
	*vega_sqlstore.ConnectionSource
	// contains filtered or unexported fields
}

func NewAssetPrices

func NewAssetPrices(connectionSource *vega_sqlstore.ConnectionSource) *AssetPrices

func (*AssetPrices) Add

func (ap *AssetPrices) Add(data *coingecko.PriceData)

func (*AssetPrices) FlushUpsert

func (ap *AssetPrices) FlushUpsert(ctx context.Context) ([]*coingecko.PriceData, error)

func (*AssetPrices) Upsert

func (ap *AssetPrices) Upsert(ctx context.Context, newAssetPrices *coingecko.PriceData) error

type BlockSigner

type BlockSigner struct {
	*vega_sqlstore.ConnectionSource
	// contains filtered or unexported fields
}

func NewBlockSigner

func NewBlockSigner(connectionSource *vega_sqlstore.ConnectionSource) *BlockSigner

func (*BlockSigner) Add

func (bs *BlockSigner) Add(data *entities.BlockSigner)

func (*BlockSigner) Flush

func (bs *BlockSigner) Flush(ctx context.Context) ([]*entities.BlockSigner, error)

func (*BlockSigner) FlushUpsert

func (bs *BlockSigner) FlushUpsert(ctx context.Context) ([]*entities.BlockSigner, error)

func (*BlockSigner) GetLastestBlockInStore

func (bs *BlockSigner) GetLastestBlockInStore(ctx context.Context) (int64, error)

func (*BlockSigner) Upsert

func (bs *BlockSigner) Upsert(ctx context.Context, newBlockSigner *entities.BlockSigner) error

type Blocks added in v0.10.0

type Blocks struct {
	*vega_sqlstore.ConnectionSource
	// contains filtered or unexported fields
}

func NewBlocks added in v0.10.0

func NewBlocks(connectionSource *vega_sqlstore.ConnectionSource) *Blocks

func (*Blocks) GetEarliestBlockHeight added in v0.11.0

func (b *Blocks) GetEarliestBlockHeight(ctx context.Context) (*int64, error)

func (*Blocks) GetLastBlock added in v0.10.0

func (b *Blocks) GetLastBlock(ctx context.Context) (*vega_entities.Block, error)

func (*Blocks) GetLastBlockHeight added in v0.11.0

func (b *Blocks) GetLastBlockHeight(ctx context.Context) (*int64, error)

func (*Blocks) GetLatestBlockWithCache added in v0.10.0

func (b *Blocks) GetLatestBlockWithCache(ctx context.Context, cacheTime time.Duration) (*vega_entities.Block, error)

type CometTxs

type CometTxs struct {
	*vega_sqlstore.ConnectionSource
	// contains filtered or unexported fields
}

func NewCometTxs

func NewCometTxs(connectionSource *vega_sqlstore.ConnectionSource) *CometTxs

func (*CometTxs) AddWithoutTime

func (nhs *CometTxs) AddWithoutTime(newTx comet.CometTx)

func (*CometTxs) FlushUpsertWithoutTime

func (c *CometTxs) FlushUpsertWithoutTime(ctx context.Context) ([]comet.CometTx, error)

func (*CometTxs) GetLatestBlockInStore added in v0.11.0

func (c *CometTxs) GetLatestBlockInStore(ctx context.Context) (int64, error)

func (*CometTxs) UpsertWithoutTime

func (nhs *CometTxs) UpsertWithoutTime(ctx context.Context, newTx comet.CometTx) error

type MonitoringStatus added in v0.9.0

type MonitoringStatus struct {
	*vega_sqlstore.ConnectionSource
	// contains filtered or unexported fields
}

func NewMonitoringStatus added in v0.9.0

func NewMonitoringStatus(connectionSource *vega_sqlstore.ConnectionSource) *MonitoringStatus

func (*MonitoringStatus) Add added in v0.9.0

func (ms *MonitoringStatus) Add(status entities.MonitoringStatus)

func (*MonitoringStatus) Clear added in v0.15.2

func (ms *MonitoringStatus) Clear() error

func (*MonitoringStatus) FlushUpsert added in v0.9.0

func (ms *MonitoringStatus) FlushUpsert(ctx context.Context) ([]entities.MonitoringStatus, error)

func (*MonitoringStatus) GetLatest added in v0.9.0

func (*MonitoringStatus) IsPendingFor added in v0.9.0

func (ms *MonitoringStatus) IsPendingFor(service entities.MonitoringServiceType) bool

func (*MonitoringStatus) UpsertSingle added in v0.9.0

func (ms *MonitoringStatus) UpsertSingle(ctx context.Context, entity entities.MonitoringStatus) error

type NetworkBalances

type NetworkBalances struct {
	*vega_sqlstore.ConnectionSource
	NetworkBalances []entities.NetworkBalance
}

func NewNetworkBalances

func NewNetworkBalances(connectionSource *vega_sqlstore.ConnectionSource) *NetworkBalances

func (*NetworkBalances) Add

func (nhs *NetworkBalances) Add(newBalance entities.NetworkBalance)

func (*NetworkBalances) FlushUpsert

func (c *NetworkBalances) FlushUpsert(ctx context.Context) ([]entities.NetworkBalance, error)

func (*NetworkBalances) Upsert added in v0.15.1

func (nhs *NetworkBalances) Upsert(ctx context.Context, newBalance entities.NetworkBalance) error

func (*NetworkBalances) UpsertPartiesTotalBalance

func (nhs *NetworkBalances) UpsertPartiesTotalBalance(ctx context.Context) error

func (*NetworkBalances) UpsertUnfinalizedDeposits

func (nhs *NetworkBalances) UpsertUnfinalizedDeposits(ctx context.Context) error

func (*NetworkBalances) UpsertUnrealisedWithdrawalsBalance

func (nhs *NetworkBalances) UpsertUnrealisedWithdrawalsBalance(ctx context.Context) error

type NetworkHistorySegment

type NetworkHistorySegment struct {
	*vega_sqlstore.ConnectionSource
	// contains filtered or unexported fields
}

func NewNetworkHistorySegment

func NewNetworkHistorySegment(connectionSource *vega_sqlstore.ConnectionSource) *NetworkHistorySegment

func (*NetworkHistorySegment) AddWithoutTime

func (nhs *NetworkHistorySegment) AddWithoutTime(data *datanode.NetworkHistorySegment)

func (*NetworkHistorySegment) FlushUpsertWithoutTime

func (nhs *NetworkHistorySegment) FlushUpsertWithoutTime(ctx context.Context) ([]*datanode.NetworkHistorySegment, error)

func (*NetworkHistorySegment) GetLatestSegmentsPerDataNode added in v0.9.0

func (nhs *NetworkHistorySegment) GetLatestSegmentsPerDataNode(ctx context.Context) ([]datanode.NetworkHistorySegment, error)

func (*NetworkHistorySegment) UpsertWithoutTime

func (nhs *NetworkHistorySegment) UpsertWithoutTime(ctx context.Context, newSegment *datanode.NetworkHistorySegment) error

type RetentionPolicies added in v0.9.0

type RetentionPolicies []RetentionPolicy

func RetentionPoliciesFromConfig added in v0.9.0

func RetentionPoliciesFromConfig(basePolicy string, overrides []config.RetentionPolicy) (RetentionPolicies, error)

type RetentionPolicy added in v0.9.0

type RetentionPolicy struct {
	TableName string
	Interval  string
}

func (RetentionPolicy) AsString added in v0.9.0

func (rp RetentionPolicy) AsString() string

type StoreType added in v0.9.0

type StoreType string
const (
	StoreAssetPool             StoreType = "asset pool"
	StoreBlockSigner           StoreType = "block signer"
	StoreCometTxs              StoreType = "comet txs"
	StoreNetworkBalances       StoreType = "network balances"
	StoreNetworkHistorySegment StoreType = "network history segment"
	StoreMonitoringStatus      StoreType = "monitoring status"
)

Jump to

Keyboard shortcuts

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