storage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInternal = errors.New("internal error")

Functions

This section is empty.

Types

type Config

type Config struct {
	Node        NodeConfig                `yaml:"node"`
	Gossip      gossip.Config             `yaml:"gossip"`
	Membership  MembershipConfig          `yaml:"membership"`
	Seeds       []string                  `yaml:"seeds"`
	Persistence PersistenceConfig         `yaml:"persistence"`
	Replication ReplicationConfig         `yaml:"replication"`
	Security    SecurityConfig            `yaml:"security"`
	Transport   transport.TransportConfig `yaml:"transport"`
	TraceConfig TraceConfig               `yaml:"trace"`
}

type MembershipConfig

type MembershipConfig struct {
	Port uint16 `yaml:"port" env:"MEMBERSHIP_PORT" required:"true" default:"50053"`
}

type NodeConfig

type NodeConfig struct {
	ID          string `yaml:"id" env:"NODE_ID" required:"true"`
	BindAddress string `yaml:"bind_address" env:"NODE_BIND_ADDRESS" required:"true" default:"0.0.0.0"`
	Port        uint16 `yaml:"port" env:"NODE_PORT" required:"true" default:"50051"`
}

type PersistenceConfig

type PersistenceConfig struct {
	WalConfig          wal.Config `yaml:"wal"`
	SnapDir            string     `yaml:"snap_dir"`
	SnapshotIntervalMs int        `yaml:"snapshot_interval"`
}

type ReplicationConfig

type ReplicationConfig struct {
}

type SecurityConfig

type SecurityConfig struct {
	Enabled bool   `yaml:"enabled" env:"SECURITY_ENABLED" default:"false"`
	CaCert  string `yaml:"ca_cert" env:"SECURITY_CA_CERT_FILE" default:"/etc/secrets/ca.crt"`
	CaKey   string `yaml:"ca_key" env:"SECURITY_CA_KEY" default:"/etc/secrets/ca.key"`
	Cert    string `yaml:"cert" env:"SECURITY_CERT" default:"/etc/secrets/tls.crt"`
	Key     string `yaml:"key" env:"SECURITY_KEY" default:"/etc/secrets/tls.key"`
}

type Storage

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

func NewStorage

func NewStorage(config *Config) (*Storage, error)

func (*Storage) ApplyDec

func (s *Storage) ApplyDec(ctx context.Context, key string, val int64) (bool, error)

func (*Storage) ApplyInc

func (s *Storage) ApplyInc(ctx context.Context, key string, val int64) (bool, error)

func (*Storage) ApplySetRegister

func (s *Storage) ApplySetRegister(ctx context.Context, key string, val []byte) (bool, error)

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, key string) (bool, error)

TODO можно ускорить не дожидаясь ответа

func (*Storage) Get

func (s *Storage) Get(ctx context.Context, key string) (val any, t crdt.CRDTType, ok bool)

нужно извлекать значение из crdt типа под мьютексом, отдавать crdt дальше не стоит, хоть они и потоко-безопасны, но от этого наверное нужно избавиться

func (*Storage) GracefulStop

func (s *Storage) GracefulStop() error

func (*Storage) Put

func (s *Storage) Put(ctx context.Context, key string, t crdt.CRDTType) error

TODO выбрать в зависимости от политики когда возвращать результат, и что делать асинхронно сейчас для тестов ответ приходит после всех операций

func (*Storage) StartUp

func (s *Storage) StartUp(ctx context.Context) error

type TraceConfig

type TraceConfig struct {
	Endpoint string `yaml:"endpoint" env:"TRACE_ENDPOINT" required:"true" default:"localhost:4318"`
	Enable   bool   `yaml:"enable" env:"TRACE_ENABLE" default:"false"`
}

Directories

Path Synopsis
mocks
Package mock_engine is a generated GoMock package.
Package mock_engine is a generated GoMock package.
v1
mocks
Package mock_updates_buffer is a generated GoMock package.
Package mock_updates_buffer is a generated GoMock package.
v1
v2
mocks
Package mock_version_manager is a generated GoMock package.
Package mock_version_manager is a generated GoMock package.
v1
wal
v1

Jump to

Keyboard shortcuts

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