store

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: GPL-3.0 Imports: 20 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 NewBasicMetrics

func NewBasicMetrics(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"
	BlockTraceDataType  DataType = "execution_block_trace"
	BadBlockDataType    DataType = "execution_bad_block"
)

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) 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) 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) 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

	// 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"
)

Jump to

Keyboard shortcuts

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