storage

package
v0.0.0-...-fead75b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

storage

Public interface in storage.go

  • Get(id []byte)
  • Has(id []byte)
  • Set(key []byte, value []byte)
  • Scan(prefix []byte)

Implementations for nats, pebble & scylladb present in files with the same name.

Documentation

Overview

Package storage provides a ScyllaDB storage implementation for managing key-value pairs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLatestBlock

func GetLatestBlock(s Storage) (uint64, error)

Types

type NatsStorage

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

func NewNatsStorage

func NewNatsStorage(opts ...NatsStorageOptsFunc) *NatsStorage

func (*NatsStorage) Get

func (s *NatsStorage) Get(id []byte) []byte

func (*NatsStorage) Has

func (s *NatsStorage) Has(id []byte) bool

func (*NatsStorage) Scan

func (s *NatsStorage) Scan(prefix []byte) [][]byte

NOTE: nats scan may take quite some time to execute because of the number of keys. nats add a default timeout of 5 seconds if we do not provide any timeout.

func (*NatsStorage) Set

func (s *NatsStorage) Set(key []byte, value []byte) error

type NatsStorageOptions

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

type NatsStorageOptsFunc

type NatsStorageOptsFunc func(*NatsStorageOptions)

func WithBucket

func WithBucket(b string) NatsStorageOptsFunc

func WithToken

func WithToken(b string) NatsStorageOptsFunc

func WithUrl

func WithUrl(u string) NatsStorageOptsFunc

type PebbleStorage

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

func NewPebbleStorage

func NewPebbleStorage(opts ...PebbleStorageOptsFunc) *PebbleStorage

func (*PebbleStorage) Get

func (p *PebbleStorage) Get(id []byte) []byte

func (*PebbleStorage) Has

func (p *PebbleStorage) Has(id []byte) bool

func (*PebbleStorage) Scan

func (p *PebbleStorage) Scan(prefix []byte) [][]byte

func (*PebbleStorage) Set

func (p *PebbleStorage) Set(id []byte, value []byte) error

type PebbleStorageOptions

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

type PebbleStorageOptsFunc

type PebbleStorageOptsFunc func(*PebbleStorageOptions)

type ScyllaStorage

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

ScyllaStorage represents a storage handler for ScyllaDB.

func NewScyllaStorage

func NewScyllaStorage() (*ScyllaStorage, error)

NewScyllaStorage creates a new instance of ScyllaStorage.

func (*ScyllaStorage) Get

func (s *ScyllaStorage) Get(id gocql.UUID) ([]byte, error)

Get retrieves the value associated with the given key from ScyllaDB.

func (*ScyllaStorage) Has

func (s *ScyllaStorage) Has(id gocql.UUID) (bool, error)

Has checks if the given key exists in ScyllaDB.

func (*ScyllaStorage) Scan

func (s *ScyllaStorage) Scan() ([]gocql.UUID, [][]byte, error)

Scan retrieves all key-value pairs from ScyllaDB.

func (*ScyllaStorage) Set

func (s *ScyllaStorage) Set(id gocql.UUID, value []byte) error

Set sets the value for the given key in ScyllaDB.

type Storage

type Storage interface {
	Get(id []byte) []byte
	Has(id []byte) bool
	Set(key []byte, value []byte) error
	Scan(prefix []byte) [][]byte
}

Jump to

Keyboard shortcuts

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