store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrAlreadyStored = errors.New("already stored")
	ErrInvalid       = errors.New("invalid")
)

Functions

func IsValidStoreType

func IsValidStoreType(st Type) bool

Types

type BasicMetrics

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

func GetBasicMetricsInstance added in v0.0.17

func GetBasicMetricsInstance(namespace, storeType string, enabled bool) *BasicMetrics

func (*BasicMetrics) ObserveCacheHit

func (m *BasicMetrics) ObserveCacheHit(itemType string)

func (*BasicMetrics) ObserveCacheMiss

func (m *BasicMetrics) ObserveCacheMiss(itemType string)

func (*BasicMetrics) ObserveItemAdded

func (m *BasicMetrics) ObserveItemAdded(itemType string)

func (*BasicMetrics) ObserveItemAddedBytes added in v0.0.11

func (m *BasicMetrics) ObserveItemAddedBytes(itemType string, size int)

func (*BasicMetrics) ObserveItemRemoved

func (m *BasicMetrics) ObserveItemRemoved(itemType string)

func (*BasicMetrics) ObserveItemRetreived

func (m *BasicMetrics) ObserveItemRetreived(itemType string)

func (*BasicMetrics) ObserveItemStored

func (m *BasicMetrics) ObserveItemStored(itemType string, count int)

func (*BasicMetrics) ObserveItemURLRetreived added in v0.0.6

func (m *BasicMetrics) ObserveItemURLRetreived(itemType string)

type Config

type Config struct {
	Type   Type            `yaml:"type"`
	Config yaml.RawMessage `yaml:"config"`
}

func (*Config) Validate

func (c *Config) Validate() error

type CopyParams added in v0.0.27

type CopyParams struct {
	Source      string
	Destination string
}

type DataType

type DataType string
const (
	UnknownDataType                  DataType = "unknown"
	BeaconStateDataType              DataType = "beacon_state"
	BeaconBlockDataType              DataType = "beacon_block"
	ExecutionPayloadEnvelopeDataType DataType = "execution_payload_envelope"
	BeaconBadBlockDataType           DataType = "beacon_bad_block"
	BeaconBadBlobDataType            DataType = "beacon_bad_blob"
	BlockTraceDataType               DataType = "execution_block_trace"
	BadBlockDataType                 DataType = "execution_bad_block"
	RawDataType                      DataType = "raw"
)

type DeleteManyError added in v0.1.0

type DeleteManyError struct {
	Failed []string
	Err    error
}

DeleteManyError reports which locations a bulk delete could not remove. A bulk delete is partial by nature: one bad key must not condemn the rest of the batch, and the caller needs the failed subset so it can retry or quarantine those locations on their own.

func (*DeleteManyError) Error added in v0.1.0

func (e *DeleteManyError) Error() string

func (*DeleteManyError) Unwrap added in v0.1.0

func (e *DeleteManyError) Unwrap() error

type FSStore added in v0.0.17

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

func NewFSStore added in v0.0.17

func NewFSStore(namespace string, log logrus.FieldLogger, config *FSStoreConfig, opts *Options) (*FSStore, error)

func (*FSStore) Copy added in v0.0.27

func (s *FSStore) Copy(ctx context.Context, params *CopyParams) error

func (*FSStore) DeleteBeaconBadBlob added in v0.0.17

func (s *FSStore) DeleteBeaconBadBlob(ctx context.Context, location string) error

func (*FSStore) DeleteBeaconBadBlock added in v0.0.17

func (s *FSStore) DeleteBeaconBadBlock(ctx context.Context, location string) error

func (*FSStore) DeleteBeaconBlock added in v0.0.17

func (s *FSStore) DeleteBeaconBlock(ctx context.Context, location string) error

func (*FSStore) DeleteBeaconState added in v0.0.17

func (s *FSStore) DeleteBeaconState(ctx context.Context, location string) error

func (*FSStore) DeleteExecutionBadBlock added in v0.0.17

func (s *FSStore) DeleteExecutionBadBlock(ctx context.Context, location string) error

func (*FSStore) DeleteExecutionBlockTrace added in v0.0.17

func (s *FSStore) DeleteExecutionBlockTrace(ctx context.Context, location string) error

func (*FSStore) DeleteExecutionPayloadEnvelope added in v0.1.0

func (s *FSStore) DeleteExecutionPayloadEnvelope(ctx context.Context, location string) error

func (*FSStore) DeleteMany added in v0.1.0

func (s *FSStore) DeleteMany(ctx context.Context, locations []string) error

DeleteMany removes objects in bulk. There is no batch primitive on a filesystem, so this is a loop that keeps going past individual failures and reports the ones that did not go, in the same shape as the object-store implementation.

func (*FSStore) Exists added in v0.0.17

func (s *FSStore) Exists(ctx context.Context, location string) (bool, error)

func (*FSStore) GetBeaconBadBlob added in v0.0.17

func (s *FSStore) GetBeaconBadBlob(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetBeaconBadBlobURL added in v0.0.17

func (s *FSStore) GetBeaconBadBlobURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetBeaconBadBlock added in v0.0.17

func (s *FSStore) GetBeaconBadBlock(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetBeaconBadBlockURL added in v0.0.17

func (s *FSStore) GetBeaconBadBlockURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetBeaconBlock added in v0.0.17

func (s *FSStore) GetBeaconBlock(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetBeaconBlockURL added in v0.0.17

func (s *FSStore) GetBeaconBlockURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetBeaconState added in v0.0.17

func (s *FSStore) GetBeaconState(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetBeaconStateURL added in v0.0.17

func (s *FSStore) GetBeaconStateURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetExecutionBadBlock added in v0.0.17

func (s *FSStore) GetExecutionBadBlock(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetExecutionBadBlockURL added in v0.0.17

func (s *FSStore) GetExecutionBadBlockURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetExecutionBlockTrace added in v0.0.17

func (s *FSStore) GetExecutionBlockTrace(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetExecutionBlockTraceURL added in v0.0.17

func (s *FSStore) GetExecutionBlockTraceURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetExecutionPayloadEnvelope added in v0.1.0

func (s *FSStore) GetExecutionPayloadEnvelope(ctx context.Context, location string) (*[]byte, error)

func (*FSStore) GetExecutionPayloadEnvelopeURL added in v0.1.0

func (s *FSStore) GetExecutionPayloadEnvelopeURL(ctx context.Context, params *GetURLParams) (string, error)

func (*FSStore) GetStorageHandshakeToken added in v0.0.17

func (s *FSStore) GetStorageHandshakeToken(ctx context.Context, node string) (string, error)

func (*FSStore) Healthy added in v0.0.17

func (s *FSStore) Healthy(ctx context.Context) error

func (*FSStore) PathPrefix added in v0.0.17

func (s *FSStore) PathPrefix() string

func (*FSStore) PreferURLs added in v0.0.17

func (s *FSStore) PreferURLs() bool

func (*FSStore) SaveBeaconBadBlob added in v0.0.17

func (s *FSStore) SaveBeaconBadBlob(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveBeaconBadBlock added in v0.0.17

func (s *FSStore) SaveBeaconBadBlock(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveBeaconBlock added in v0.0.17

func (s *FSStore) SaveBeaconBlock(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveBeaconState added in v0.0.17

func (s *FSStore) SaveBeaconState(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveExecutionBadBlock added in v0.0.17

func (s *FSStore) SaveExecutionBadBlock(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveExecutionBlockTrace added in v0.0.17

func (s *FSStore) SaveExecutionBlockTrace(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveExecutionPayloadEnvelope added in v0.1.0

func (s *FSStore) SaveExecutionPayloadEnvelope(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveRaw added in v0.1.0

func (s *FSStore) SaveRaw(ctx context.Context, params *SaveParams) (string, error)

func (*FSStore) SaveStorageHandshakeToken added in v0.0.17

func (s *FSStore) SaveStorageHandshakeToken(ctx context.Context, node, data string) error

func (*FSStore) StorageHandshakeTokenExists added in v0.0.17

func (s *FSStore) StorageHandshakeTokenExists(ctx context.Context, node string) (bool, error)

type FSStoreConfig added in v0.0.17

type FSStoreConfig struct {
	BasePath string `yaml:"base_path"`
}

type GetURLParams added in v0.0.25

type GetURLParams struct {
	Location        string
	Expiry          int
	ContentEncoding string
}

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 S3Store

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

func NewS3Store

func NewS3Store(namespace string, log logrus.FieldLogger, config *S3StoreConfig, opts *Options) (*S3Store, error)

NewS3Store creates a new S3Store instance with the specified AWS configuration, bucket name, and key prefix.

func (*S3Store) Copy added in v0.0.27

func (s *S3Store) Copy(ctx context.Context, params *CopyParams) error

func (*S3Store) DeleteBeaconBadBlob added in v0.0.16

func (s *S3Store) DeleteBeaconBadBlob(ctx context.Context, location string) error

func (*S3Store) DeleteBeaconBadBlock added in v0.0.16

func (s *S3Store) DeleteBeaconBadBlock(ctx context.Context, location string) error

func (*S3Store) DeleteBeaconBlock added in v0.0.16

func (s *S3Store) DeleteBeaconBlock(ctx context.Context, location string) error

func (*S3Store) DeleteBeaconState

func (s *S3Store) DeleteBeaconState(ctx context.Context, location string) error

func (*S3Store) DeleteExecutionBadBlock

func (s *S3Store) DeleteExecutionBadBlock(ctx context.Context, location string) error

func (*S3Store) DeleteExecutionBlockTrace

func (s *S3Store) DeleteExecutionBlockTrace(ctx context.Context, location string) error

func (*S3Store) DeleteExecutionPayloadEnvelope added in v0.1.0

func (s *S3Store) DeleteExecutionPayloadEnvelope(ctx context.Context, location string) error

func (*S3Store) DeleteMany added in v0.1.0

func (s *S3Store) DeleteMany(ctx context.Context, locations []string) error

DeleteMany removes objects in bulk. Keys are sent in DeleteObjects batches; a batch that fails wholesale and individual per-key errors both surface as failed locations rather than aborting the remaining batches, because retention deletes a mixed bag of objects and one poisoned key must not keep the rest alive forever.

func (*S3Store) Exists

func (s *S3Store) Exists(ctx context.Context, location string) (bool, error)

func (*S3Store) GetBeaconBadBlob added in v0.0.16

func (s *S3Store) GetBeaconBadBlob(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetBeaconBadBlobURL added in v0.0.16

func (s *S3Store) GetBeaconBadBlobURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetBeaconBadBlock added in v0.0.16

func (s *S3Store) GetBeaconBadBlock(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetBeaconBadBlockURL added in v0.0.16

func (s *S3Store) GetBeaconBadBlockURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetBeaconBlock added in v0.0.16

func (s *S3Store) GetBeaconBlock(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetBeaconBlockURL added in v0.0.16

func (s *S3Store) GetBeaconBlockURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetBeaconState

func (s *S3Store) GetBeaconState(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetBeaconStateURL added in v0.0.6

func (s *S3Store) GetBeaconStateURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetExecutionBadBlock

func (s *S3Store) GetExecutionBadBlock(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetExecutionBadBlockURL added in v0.0.6

func (s *S3Store) GetExecutionBadBlockURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetExecutionBlockTrace

func (s *S3Store) GetExecutionBlockTrace(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetExecutionBlockTraceURL added in v0.0.6

func (s *S3Store) GetExecutionBlockTraceURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetExecutionPayloadEnvelope added in v0.1.0

func (s *S3Store) GetExecutionPayloadEnvelope(ctx context.Context, location string) (*[]byte, error)

func (*S3Store) GetExecutionPayloadEnvelopeURL added in v0.1.0

func (s *S3Store) GetExecutionPayloadEnvelopeURL(ctx context.Context, params *GetURLParams) (string, error)

func (*S3Store) GetRaw

func (s *S3Store) GetRaw(ctx context.Context, location string) (*bytes.Buffer, error)

func (*S3Store) GetStorageHandshakeToken

func (s *S3Store) GetStorageHandshakeToken(ctx context.Context, node string) (string, error)

func (*S3Store) Healthy

func (s *S3Store) Healthy(ctx context.Context) error

func (*S3Store) PathPrefix

func (s *S3Store) PathPrefix() string

func (*S3Store) PreferURLs added in v0.0.6

func (s *S3Store) PreferURLs() bool

func (*S3Store) SaveBeaconBadBlob added in v0.0.16

func (s *S3Store) SaveBeaconBadBlob(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveBeaconBadBlock added in v0.0.16

func (s *S3Store) SaveBeaconBadBlock(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveBeaconBlock added in v0.0.16

func (s *S3Store) SaveBeaconBlock(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveBeaconState

func (s *S3Store) SaveBeaconState(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveExecutionBadBlock

func (s *S3Store) SaveExecutionBadBlock(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveExecutionBlockTrace

func (s *S3Store) SaveExecutionBlockTrace(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveExecutionPayloadEnvelope added in v0.1.0

func (s *S3Store) SaveExecutionPayloadEnvelope(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveRaw added in v0.1.0

func (s *S3Store) SaveRaw(ctx context.Context, params *SaveParams) (string, error)

func (*S3Store) SaveStorageHandshakeToken

func (s *S3Store) SaveStorageHandshakeToken(ctx context.Context, node, data string) error

func (*S3Store) StorageHandshakeTokenExists

func (s *S3Store) StorageHandshakeTokenExists(ctx context.Context, node string) (bool, error)

type S3StoreConfig

type S3StoreConfig struct {
	Endpoint     string `yaml:"endpoint"`
	Region       string `yaml:"region"`
	BucketName   string `yaml:"bucket_name"`
	KeyPrefix    string `yaml:"key_prefix"`
	AccessKey    string `yaml:"access_key"`
	AccessSecret string `yaml:"access_secret"`
	UsePathStyle bool   `yaml:"use_path_style"`
	PreferURLs   bool   `yaml:"prefer_urls"`
}

type SaveParams added in v0.0.25

type SaveParams struct {
	// Data is streamed to the backend rather than buffered, so the caller may
	// hand over a pipe whose length is not known up front. A reader that fails
	// part way through must leave nothing published: every implementation
	// either aborts the transfer or discards the partial object.
	Data            io.Reader
	Location        string
	ContentEncoding string
}

type Store

type Store interface {
	// Healthy checks if the store is healthy
	Healthy(ctx context.Context) error
	// Exists checks if the file exists in the store
	Exists(ctx context.Context, location string) (bool, error)

	// Copy copies a file from one location to another
	Copy(ctx context.Context, params *CopyParams) error

	// DeleteMany removes objects in bulk regardless of their data type. A location that is
	// already absent counts as removed. When some locations cannot be removed the returned
	// error is a *DeleteManyError naming exactly those, so the caller can retry or
	// quarantine them without re-deleting the rest.
	DeleteMany(ctx context.Context, locations []string) error

	// SaveRaw saves arbitrary bytes to the store at the given location
	SaveRaw(ctx context.Context, params *SaveParams) (string, error)

	// StorageHandshakeTokenExists checks if a storage handshake token exists in the store
	StorageHandshakeTokenExists(ctx context.Context, node string) (bool, error)
	// SaveStorageHandshakeToken saves a storage handshake token to the store
	SaveStorageHandshakeToken(ctx context.Context, node, data string) error
	// GetStorageHandshake fetches a storage handshake token from the store
	GetStorageHandshakeToken(ctx context.Context, node string) (string, error)

	// SaveBeaconState saves a beacon state to the store
	SaveBeaconState(ctx context.Context, params *SaveParams) (string, error)
	// GetBeaconState fetches a beacon state from the store
	GetBeaconState(ctx context.Context, location string) (*[]byte, error)
	// GetBeaconStateURL returns a URL for the beacon state
	GetBeaconStateURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteBeaconState deletes a beacon state from the store
	DeleteBeaconState(ctx context.Context, location string) error

	// SaveBeaconBlock saves a beacon block to the store
	SaveBeaconBlock(ctx context.Context, params *SaveParams) (string, error)
	// GetBeaconBlock fetches a beacon block from the store
	GetBeaconBlock(ctx context.Context, location string) (*[]byte, error)
	// GetBeaconBlockURL returns a URL for the beacon block
	GetBeaconBlockURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteBeaconBlock deletes a beacon block from the store
	DeleteBeaconBlock(ctx context.Context, location string) error
	// SaveExecutionPayloadEnvelope saves an execution payload envelope to the store
	SaveExecutionPayloadEnvelope(ctx context.Context, params *SaveParams) (string, error)
	// GetExecutionPayloadEnvelope fetches an execution payload envelope from the store
	GetExecutionPayloadEnvelope(ctx context.Context, location string) (*[]byte, error)
	// GetExecutionPayloadEnvelopeURL returns a URL for the execution payload envelope
	GetExecutionPayloadEnvelopeURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteExecutionPayloadEnvelope deletes an execution payload envelope from the store
	DeleteExecutionPayloadEnvelope(ctx context.Context, location string) error

	// SaveBeaconBadBlock saves a beacon bad block to the store
	SaveBeaconBadBlock(ctx context.Context, params *SaveParams) (string, error)
	// GetBeaconBadBlock fetches a beacon bad block from the store
	GetBeaconBadBlock(ctx context.Context, location string) (*[]byte, error)
	// GetBeaconBadBlockURL returns a URL for the beacon bad block
	GetBeaconBadBlockURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteBeaconBadBlock deletes a beacon bad block from the store
	DeleteBeaconBadBlock(ctx context.Context, location string) error

	// SaveBeaconBadBlob saves a beacon bad block to the store
	SaveBeaconBadBlob(ctx context.Context, params *SaveParams) (string, error)
	// GetBeaconBadBlob fetches a beacon bad block from the store
	GetBeaconBadBlob(ctx context.Context, location string) (*[]byte, error)
	// GetBeaconBadBlobURL returns a URL for the beacon bad block
	GetBeaconBadBlobURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteBeaconBadBlob deletes a beacon bad block from the store
	DeleteBeaconBadBlob(ctx context.Context, location string) error

	// SaveExecutionBlockTrace saves an execution block trace to the store
	SaveExecutionBlockTrace(ctx context.Context, params *SaveParams) (string, error)
	// GetExecutionBlockTrace fetches an execution block trace from the store
	GetExecutionBlockTrace(ctx context.Context, location string) (*[]byte, error)
	// GetExecutionBlockTraceURL returns a URL for the execution block trace
	GetExecutionBlockTraceURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteExecutionBlockTrace deletes an execution block trace from the store
	DeleteExecutionBlockTrace(ctx context.Context, location string) error

	// SaveExecutionBadBlock saves an execution bad block to the store
	SaveExecutionBadBlock(ctx context.Context, params *SaveParams) (string, error)
	// GetExecutionBadBlock fetches an execution bad block from the store
	GetExecutionBadBlock(ctx context.Context, location string) (*[]byte, error)
	// GetExecutionBadBlockURL returns a URL for the execution bad block
	GetExecutionBadBlockURL(ctx context.Context, params *GetURLParams) (string, error)
	// DeleteExecutionBadBlock deletes an execution bad block from the store
	DeleteExecutionBadBlock(ctx context.Context, location string) error

	// PathPrefix returns the path prefix for the store
	PathPrefix() string
	// PreferURLs returns if the store prefers URLs for serving data
	PreferURLs() bool
}

Store is an interface for different persistence implementations.

func NewMockS3Store added in v0.0.15

func NewMockS3Store(ctx context.Context, bucket string) (Store, func() error, error)

func NewStore

func NewStore(namespace string, log logrus.FieldLogger, storeType Type, config yaml.RawMessage, opts *Options) (Store, error)

type Type

type Type string
const (
	UnknownStore Type = "unknown"
	S3StoreType  Type = "s3"
	FSStoreType  Type = "fs"
)

Jump to

Keyboard shortcuts

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