mokv

package
v0.0.0-...-bc4c7a2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides access to a mökv cluster.

func NewClient

func NewClient(addr string) (*Client, error)

NewClient connects to a mökv node at the given address.

func (*Client) Close

func (c *Client) Close() error

Close releases the underlying connection.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string) (bool, error)

Delete removes a key from the cluster.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) ([]byte, error)

Get retrieves a value by key. Returns nil if the key does not exist.

func (*Client) GetServers

func (c *Client) GetServers(ctx context.Context) ([]Server, error)

GetServers returns all nodes in the cluster.

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, value []byte) (bool, error)

Set stores a key-value pair, replicating it across the cluster.

type Config

type Config struct {
	DataDir        string
	NodeName       string
	BindAddr       string
	RPCPort        int
	MetricsPort    int
	StartJoinAddrs []string
	Bootstrap      bool
	LogLevel       string
}

Config holds the configuration parameters for the MOKV server node.

type GetEnv

type GetEnv func(string) string

GetEnv defines a function signature for retrieving environment variables.

type MOKV

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

MOKV represents the main server instance orchestrating gRPC, Raft, and Discovery services.

func New

func New(cfg *Config, getEnv GetEnv) (*MOKV, error)

New initializes a new MOKV server instance with the provided configuration.

func (*MOKV) Listen

func (m *MOKV) Listen(ctx context.Context) error

type Server

type Server struct {
	RpcAddr  string
	IsLeader bool
	ID       string
}

Server represents a node in the cluster.

type Storer

type Storer interface {
	Get(key string) ([]byte, error)
	Set(key string, value []byte) error
	Delete(key string) error
	List() <-chan []byte
	Close() error
}

Storer defines the interface for a the key-value storage.

Jump to

Keyboard shortcuts

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