db

package
v0.0.54 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: GPL-3.0 Imports: 13 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 EventSource added in v0.0.46

type EventSource int
const (
	NilEventSource EventSource = iota
	UnknownEventSource
	BeaconNodeEventSource
	XatuPollingEventSource
	XatuReorgEventEventSource
)

func NewEventSource added in v0.0.46

func NewEventSource(i int) EventSource

func NewEventSourceFromString added in v0.0.46

func NewEventSourceFromString(s string) EventSource

func NewEventSourceFromType added in v0.0.46

func NewEventSourceFromType(s types.EventSource) EventSource

func (EventSource) String added in v0.0.46

func (e EventSource) String() string

type FrameFilter

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

func (*FrameFilter) AddAfter

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

func (*FrameFilter) AddBefore

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

func (*FrameFilter) AddConsensusClient added in v0.0.46

func (f *FrameFilter) AddConsensusClient(consensusClient string)

func (*FrameFilter) AddEpoch

func (f *FrameFilter) AddEpoch(epoch uint64)

func (*FrameFilter) AddEventSource added in v0.0.46

func (f *FrameFilter) AddEventSource(eventSource int)

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;"`
	ConsensusClient string               `gorm:"not null;default:''"`
	EventSource     EventSource          `gorm:"not null;default:0"`
}

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) DeleteFrameMetadataLabels added in v0.0.46

func (i *Indexer) DeleteFrameMetadataLabels(ctx context.Context, ids []uint) error

func (*Indexer) DeleteFrameMetadataLabelsByName added in v0.0.46

func (i *Indexer) DeleteFrameMetadataLabelsByName(ctx context.Context, name string) (uint64, 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

func (*Indexer) UpdateFrameMetadata added in v0.0.46

func (i *Indexer) UpdateFrameMetadata(ctx context.Context, metadata *FrameMetadata) 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"
	OperationUpdateFrameMetadata Operation = "update_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"

	OperationDeleteFrameMetadataLabelsByIDs  Operation = "delete_frame_metadata_labels_by_ids"
	OperationDeleteFrameMetadataLabelsByName Operation = "delete_frame_metadata_labels_by_name"
)

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