storage

package
v1.0.10-0...-7349ede Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SaveJetDropDataDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_SaveJetDropDataDuration",
		Help:       "The duration of the SaveJetDropData function execution",
		Objectives: quntitile,
	})
	SavePulseDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_SavePulseDuration",
		Help:       "The duration of the SavePulse function execution",
		Objectives: quntitile,
	})
	CompletePulseDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_CompletePulseDuration",
		Help:       "The duration of the CompletePulse function execution",
		Objectives: quntitile,
	})
	SequencePulseDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_SequencePulseDuration",
		Help:       "The duration of the SequencePulse function execution",
		Objectives: quntitile,
	})
	GetRecordDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetRecordDuration",
		Help:       "The duration of the GetRecord function execution",
		Objectives: quntitile,
	})
	GetLifelineDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetLifelineDuration",
		Help:       "The duration of the GetLifeline function execution",
		Objectives: quntitile,
	})
	GetPulseDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetPulseDuration",
		Help:       "The duration of the GetPulse function execution",
		Objectives: quntitile,
	})
	GetPulsesDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetPulsesDuration",
		Help:       "The duration of the GetPulses function execution",
		Objectives: quntitile,
	})
	GetRecordsByJetDropDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetRecordsByJetDropDuration",
		Help:       "The duration of the GetRecordsByJetDrop function execution",
		Objectives: quntitile,
	})
	GetIncompletePulsesDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetIncompletePulsesDuration",
		Help:       "The duration of the GetIncompletePulses function execution",
		Objectives: quntitile,
	})
	GetPulseByPrevDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetPulseByPrevDuration",
		Help:       "The duration of the GetPulseByPrev function execution",
		Objectives: quntitile,
	})
	GetSequentialPulseDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetSequentialPulseDuration",
		Help:       "The duration of the GetSequentialPulse function execution",
		Objectives: quntitile,
	})
	GetNextSavedPulseDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetNextSavedPulseDuration",
		Help:       "The duration of the GetNextSavedPulse function execution",
		Objectives: quntitile,
	})
	GetJetDropsDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetJetDropsDuration",
		Help:       "The duration of the GetJetDrops function execution",
		Objectives: quntitile,
	})
	GetJetDropsWithParamsDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetJetDropsWithParamsDuration",
		Help:       "The duration of the GetJetDropsWithParams function execution",
		Objectives: quntitile,
	})
	GetJetDropByIDDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetJetDropByIDDuration",
		Help:       "The duration of the GetJetDropByID function execution",
		Objectives: quntitile,
	})
	GetJetDropsByJetIDDuration = prometheus.NewSummary(prometheus.SummaryOpts{
		Name:       "gbe_storage_stats_GetJetDropsByJetIDDuration",
		Help:       "The duration of the GetJetDropsByJetID function execution",
		Objectives: quntitile,
	})
)

Functions

func CheckIndex

func CheckIndex(i string) (int, int, error)

func GetJetIDParents

func GetJetIDParents(jetID string) []string

GetJetIDParents returns parents of the jet id "0010" -> [” 0 00 001 0010]

Types

type DBStats

type DBStats struct {
	*gorm.DB

	MaxOpenConnections prometheus.Gauge // Maximum number of open connections to the database.

	// Pool status
	OpenConnections prometheus.Gauge // The number of established connections both in use and idle.
	InUse           prometheus.Gauge // The number of connections currently in use.
	Idle            prometheus.Gauge // The number of idle connections.

	// Counters
	WaitCount         prometheus.Gauge // The total number of connections waited for.
	WaitDuration      prometheus.Gauge // The total time blocked waiting for a new connection.
	MaxIdleClosed     prometheus.Gauge // The total number of connections closed due to SetMaxIdleConns.
	MaxLifetimeClosed prometheus.Gauge // The total number of connections closed due to SetConnMaxLifetime.
}

func NewStatsCollector

func NewStatsCollector(db *gorm.DB, labels map[string]string) *DBStats

func (*DBStats) Collectors

func (stats *DBStats) Collectors() (collector []prometheus.Collector)

Collectors returns collector in stats

func (*DBStats) Metrics

func (stats *DBStats) Metrics(p *metrics.Prometheus) []prometheus.Collector

func (*DBStats) Refresh

func (stats *DBStats) Refresh()

func (*DBStats) Set

func (stats *DBStats) Set(dbStats sql.DBStats)

Set updates the metrics value

type Metrics

type Metrics struct{}

The storage function metrics

func (Metrics) Metrics

func (s Metrics) Metrics(p *metrics.Prometheus) []prometheus.Collector

func (Metrics) Refresh

func (s Metrics) Refresh()

type PostgresCollector

type PostgresCollector struct {
	*PostgresCollectorConfig

	*gorm.DB
	Logger log.Logger
	// contains filtered or unexported fields
}

func NewPostgresCollector

func NewPostgresCollector(config *PostgresCollectorConfig, db *gorm.DB) *PostgresCollector

func (*PostgresCollector) Metrics

func (*PostgresCollector) Refresh

func (pg *PostgresCollector) Refresh()

type PostgresCollectorConfig

type PostgresCollectorConfig struct {
	Prefix   string
	Interval time.Duration
	Labels   map[string]string
}

type Storage

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

func NewStorage

func NewStorage(db *gorm.DB) *Storage

NewStorage returns implementation of interfaces.Storage

func (*Storage) CompletePulse

func (s *Storage) CompletePulse(pulseNumber int64) error

CompletePulse update pulse with provided number to completeness in db.

func (*Storage) GetIncompletePulses

func (s *Storage) GetIncompletePulses() ([]models.Pulse, error)

GetIncompletePulses returns pulses that are not complete from db.

func (*Storage) GetJetDropByID

func (s *Storage) GetJetDropByID(id models.JetDropID) (models.JetDrop, []models.JetDrop, []models.JetDrop, error)

func (*Storage) GetJetDrops

func (s *Storage) GetJetDrops(pulse models.Pulse) ([]models.JetDrop, error)

GetJetDrops returns jetDrops for provided pulse from db.

func (*Storage) GetJetDropsByJetID

func (s *Storage) GetJetDropsByJetID(jetID string, pulseNumberLte, pulseNumberLt, pulseNumberGte, pulseNumberGt *int64, limit int, sortByPnAsc bool) ([]models.JetDrop, int, error)

func (*Storage) GetJetDropsWithParams

func (s *Storage) GetJetDropsWithParams(pulse models.Pulse, fromJetDropID *models.JetDropID, limit int, offset int) ([]models.JetDrop, int, error)

func (*Storage) GetLifeline

func (s *Storage) GetLifeline(objRef []byte, fromIndex *string, pulseNumberLt, pulseNumberGt, timestampLte, timestampGte *int64, limit, offset int, sortByIndexAsc bool) ([]models.Record, int, error)

GetLifeline returns records for provided object reference, ordered by pulse number and order fields.

func (*Storage) GetNextCompletePulseFilterByPrototypeReference

func (s *Storage) GetNextCompletePulseFilterByPrototypeReference(prevPulse int64, prototypes [][]byte) (models.Pulse, error)

func (*Storage) GetNextSavedPulse

func (s *Storage) GetNextSavedPulse(fromPulseNumber models.Pulse, completedOnly bool) (models.Pulse, error)

GetNextSavedPulse returns first pulse with pulse number bigger then fromPulseNumber from db.

func (*Storage) GetPulse

func (s *Storage) GetPulse(pulseNumber int64) (models.Pulse, error)

GetPulse returns pulse with provided pulse number from db.

func (*Storage) GetPulseByPrev

func (s *Storage) GetPulseByPrev(prevPulse models.Pulse) (models.Pulse, error)

GetPulseByPrev returns pulse with provided prev pulse number from db.

func (*Storage) GetPulses

func (s *Storage) GetPulses(fromPulse *int64, timestampLte, timestampGte, pulseNumberLte, pulseNumberLt, pulseNumberGte, pulseNumberGt *int64, sortByAsc bool, limit, offset int) ([]models.Pulse, int, error)

GetPulses returns pulses from db.

func (*Storage) GetRecord

func (s *Storage) GetRecord(ref models.Reference) (models.Record, error)

GetJetDrops returns records with provided reference from db.

func (*Storage) GetRecordsByJetDrop

func (s *Storage) GetRecordsByJetDrop(jetDropID models.JetDropID, fromIndex, recordType *string, limit, offset int) ([]models.Record, int, error)

GetRecordsByJetDrop returns records for provided jet drop, ordered by order field.

func (*Storage) GetSequentialPulse

func (s *Storage) GetSequentialPulse() (models.Pulse, error)

GetSequentialPulse returns max pulse that have is_sequential as true from db.

func (*Storage) SaveJetDropData

func (s *Storage) SaveJetDropData(jetDrop models.JetDrop, records []models.Record, pulseNumber int64) error

SaveJetDropData saves provided jetDrop and records to db in one transaction. increase jet_drop_amount and record_amount

func (*Storage) SavePulse

func (s *Storage) SavePulse(pulse models.Pulse) error

SavePulse saves provided pulse to db.

func (*Storage) SequencePulse

func (s *Storage) SequencePulse(pulseNumber int64) error

SequencePulse update pulse with provided number to sequential in db.

Jump to

Keyboard shortcuts

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