db

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicMetrics

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

func NewBasicMetrics

func NewBasicMetrics(namespace, driverName string, enabled bool) *BasicMetrics

func (*BasicMetrics) ObserveOperation

func (m *BasicMetrics) ObserveOperation(operation Operation)

func (*BasicMetrics) ObserveOperationError

func (m *BasicMetrics) ObserveOperationError(operation Operation)

type FrameFilter

type FrameFilter struct {
	ID     *string
	Node   *string
	Before *time.Time
	After  *time.Time
	Slot   *uint64
	Epoch  *uint64
	Labels *[]string
}

func (*FrameFilter) AddAfter

func (f *FrameFilter) AddAfter(after time.Time)

func (*FrameFilter) AddBefore

func (f *FrameFilter) AddBefore(before time.Time)

func (*FrameFilter) AddEpoch

func (f *FrameFilter) AddEpoch(epoch uint64)

func (*FrameFilter) AddID

func (f *FrameFilter) AddID(id string)

func (*FrameFilter) AddLabels

func (f *FrameFilter) AddLabels(labels []string)

func (*FrameFilter) AddNode

func (f *FrameFilter) AddNode(node string)

func (*FrameFilter) AddSlot

func (f *FrameFilter) AddSlot(slot uint64)

func (*FrameFilter) ApplyToQuery

func (f *FrameFilter) ApplyToQuery(query *gorm.DB) (*gorm.DB, error)

func (*FrameFilter) Validate

func (f *FrameFilter) Validate() error

type FrameMetadata

type FrameMetadata struct {
	gorm.Model
	ID   string `gorm:"primaryKey"`
	Node string `gorm:"index"`
	// We have to use int64 here as SQLite doesn't support uint64. This sucks
	// but slot 9223372036854775808 is probably around the heat death
	// of the universe so we should be OK.
	WallClockSlot  int64 `gorm:"index:idx_wall_clock_slot,where:deleted_at IS NULL"`
	WallClockEpoch int64
	FetchedAt      time.Time            `gorm:"index"`
	Labels         []FrameMetadataLabel `gorm:"foreignkey:FrameID;"`
}

func (*FrameMetadata) AsFrameMetadata

func (f *FrameMetadata) AsFrameMetadata() *types.FrameMetadata

func (*FrameMetadata) FromFrameMetadata

func (f *FrameMetadata) FromFrameMetadata(metadata *types.FrameMetadata) *FrameMetadata

type FrameMetadataLabel

type FrameMetadataLabel struct {
	gorm.Model
	Name      string    `gorm:"index:idx_name_created_at_deleted_at,where:deleted_at IS NULL"`
	FrameID   string    `gorm:"index"`
	CreatedAt time.Time `gorm:"index:idx_name_created_at_deleted_at,where:deleted_at IS NULL"`
}

type FrameMetadataLabels

type FrameMetadataLabels []FrameMetadataLabel

func (*FrameMetadataLabels) AsStrings

func (f *FrameMetadataLabels) AsStrings() []string

type FrameMetadatas

type FrameMetadatas []*FrameMetadata

func (*FrameMetadatas) AsFrameMetadata

func (f *FrameMetadatas) AsFrameMetadata() []*types.FrameMetadata

type Indexer

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

func NewIndexer

func NewIndexer(namespace string, log logrus.FieldLogger, config IndexerConfig, opts *Options) (*Indexer, error)

func (*Indexer) CountEpochsWithFrames

func (i *Indexer) CountEpochsWithFrames(ctx context.Context, filter *FrameFilter) (int64, error)

func (*Indexer) CountFrameMetadata

func (i *Indexer) CountFrameMetadata(ctx context.Context, filter *FrameFilter) (int64, error)

func (*Indexer) CountLabelsWithFrames

func (i *Indexer) CountLabelsWithFrames(ctx context.Context, filter *FrameFilter) (int64, error)

func (*Indexer) CountNodesWithFrames

func (i *Indexer) CountNodesWithFrames(ctx context.Context, filter *FrameFilter) (int64, error)

func (*Indexer) CountSlotsWithFrames

func (i *Indexer) CountSlotsWithFrames(ctx context.Context, filter *FrameFilter) (int64, error)

func (*Indexer) DeleteFrameMetadata

func (i *Indexer) DeleteFrameMetadata(ctx context.Context, id string) error

func (*Indexer) InsertFrameMetadata

func (i *Indexer) InsertFrameMetadata(ctx context.Context, metadata *types.FrameMetadata) error

func (*Indexer) ListEpochsWithFrames

func (i *Indexer) ListEpochsWithFrames(ctx context.Context, filter *FrameFilter, page *PaginationCursor) ([]phase0.Epoch, error)

func (*Indexer) ListFrameMetadata

func (i *Indexer) ListFrameMetadata(ctx context.Context, filter *FrameFilter, page *PaginationCursor) ([]*FrameMetadata, error)

func (*Indexer) ListLabelsWithFrames

func (i *Indexer) ListLabelsWithFrames(ctx context.Context, filter *FrameFilter, page *PaginationCursor) (FrameMetadataLabels, error)

func (*Indexer) ListNodesWithFrames

func (i *Indexer) ListNodesWithFrames(ctx context.Context, filter *FrameFilter, page *PaginationCursor) ([]string, error)

func (*Indexer) ListSlotsWithFrames

func (i *Indexer) ListSlotsWithFrames(ctx context.Context, filter *FrameFilter, page *PaginationCursor) ([]phase0.Slot, error)

func (*Indexer) RemoveFrameMetadata

func (i *Indexer) RemoveFrameMetadata(ctx context.Context, id string) error

type IndexerConfig

type IndexerConfig struct {
	DSN        string `yaml:"dsn"`
	DriverName string `yaml:"driver_name"`
}

type Operation

type Operation string
const (
	OperationInsertFrameMetadata Operation = "insert_frame_metadata"
	OperationDeleteFrameMetadata Operation = "delete_frame_metadata"
	OperationCountFrameMetadata  Operation = "count_frame_metadata"
	OperationListFrameMetadata   Operation = "list_frame_metadata"

	OperationCountNodesWithFrames Operation = "count_nodes_with_frames"
	OperationsListNodesWithFrames Operation = "list_nodes_with_frames"

	OperationCountSlotsWithFrames Operation = "count_slots_with_frames"
	OperationListSlotsWithFrames  Operation = "list_slots_with_frames"

	OperationCountEpochsWithFrames Operation = "count_epochs_with_frames"
	OperationListEpochsWithFrames  Operation = "list_epochs_with_frames"

	OperationCountLabelsWithFrames Operation = "count_labels_with_frames"
	OperationListLabelsWithFrames  Operation = "list_labels_with_frames"
)

type Options

type Options struct {
	MetricsEnabled bool
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) SetMetricsEnabled

func (o *Options) SetMetricsEnabled(enabled bool) *Options

func (*Options) Validate

func (o *Options) Validate() error

func (*Options) WithMetricsDisabled

func (o *Options) WithMetricsDisabled() *Options

func (*Options) WithMetricsEnabled

func (o *Options) WithMetricsEnabled() *Options

type PaginationCursor

type PaginationCursor struct {
	// The cursor to start from.
	Offset int `json:"offset"`
	// The number of items to return.
	Limit int `json:"limit"`
	// OrderBy is the column to order by.
	OrderBy string `json:"order_by"`
}

func (*PaginationCursor) ApplyOffsetLimit added in v0.0.14

func (p *PaginationCursor) ApplyOffsetLimit(query *gorm.DB) *gorm.DB

func (*PaginationCursor) ApplyOrderBy added in v0.0.14

func (p *PaginationCursor) ApplyOrderBy(query *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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