store

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: GPL-3.0 Imports: 23 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 GzipCompress

func GzipCompress(data []byte) ([]byte, error)

func GzipDecompress

func GzipDecompress(data []byte) ([]byte, error)

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) ObserveItemAddedBytesUncompressed added in v0.0.11

func (m *BasicMetrics) ObserveItemAddedBytesUncompressed(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 DataType

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

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) 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) 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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, data *[]byte, location string) (string, error)

func (*FSStore) SaveBeaconBadBlock added in v0.0.17

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

func (*FSStore) SaveBeaconBlock added in v0.0.17

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

func (*FSStore) SaveBeaconState added in v0.0.17

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

func (*FSStore) SaveExecutionBadBlock added in v0.0.17

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

func (*FSStore) SaveExecutionBlockTrace added in v0.0.17

func (s *FSStore) SaveExecutionBlockTrace(ctx context.Context, data *[]byte, location string) (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 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) 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) 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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, location string, expiry int) (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, data *[]byte, location string) (string, error)

func (*S3Store) SaveBeaconBadBlock added in v0.0.16

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

func (*S3Store) SaveBeaconBlock added in v0.0.16

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

func (*S3Store) SaveBeaconState

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

func (*S3Store) SaveExecutionBadBlock

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

func (*S3Store) SaveExecutionBlockTrace

func (s *S3Store) SaveExecutionBlockTrace(ctx context.Context, data *[]byte, location string) (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 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)

	// 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, data *[]byte, location string) (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, location string, expiry int) (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, data *[]byte, location string) (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, location string, expiry int) (string, error)
	// DeleteBeaconBlock deletes a beacon block from the store
	DeleteBeaconBlock(ctx context.Context, location string) error

	// SaveBeaconBadBlock saves a beacon bad block to the store
	SaveBeaconBadBlock(ctx context.Context, data *[]byte, location string) (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, location string, expiry int) (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, data *[]byte, location string) (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, location string, expiry int) (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, data *[]byte, location string) (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, location string, expiry int) (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, data *[]byte, location string) (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, location string, expiry int) (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