sqlstore

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 21 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 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 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) GetLastestBlockInStore

func (c *CometTxs) GetLastestBlockInStore(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) FlushClear added in v0.9.0

FlushClear does not flush the events, it just clear the buffer up and return all the events to the caller

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) 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

func (*NetworkBalances) UpsertWithoutAssetId

func (nhs *NetworkBalances) UpsertWithoutAssetId(ctx context.Context, newBalance entities.NetworkBalance) 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