rangedb

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 32 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultTCPPort = 12359
	DefaultWSPort  = 80
)

The default ports that the rangedb server listens on.

Variables

View Source
var (
	ErrNilClient = errors.New("uninitialised client")
)

errors

Functions

func AreEqual added in v0.0.13

func AreEqual(c *ClientConfig, d *ClientConfig) bool

AreEqual returns true iff the two configurations are equal.

Types

type Client

type Client struct {
	log.BasicLogable
	io.Closer
	// contains filtered or unexported fields
}

Client is the client-view of the server.

func NewClient

func NewClient(ctx context.Context, cfg *ClientConfig) (*Client, error)

NewClient returns a new client view of the server specified by the configuration cfg.

func (*Client) Create

func (c *Client) Create(ctx context.Context, name string, r irange.Range, lifetime time.Duration, maxRetries int, maxConcurrency int) error

Create creates a range r with given name. Entries have the given lifetime; they are retried at most maxRetries times on failure, and at most maxConcurrency entries can be active at the same time. If a range with that name already exists, Create returns ErrRangeExists.

func (*Client) Delete

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

Delete deletes the range with the given name

func (*Client) Error

func (c *Client) Error(ctx context.Context, id irange.ID) error

Error indicates that the entry with the given ID has failed and should be retried.

func (*Client) Fatal

func (c *Client) Fatal(ctx context.Context, id irange.ID) error

Fatal indicates that the entry with the given ID has failed and should not be requeued.

func (*Client) Info

func (c *Client) Info(ctx context.Context, name string, entry int64) (irange.Info, error)

Info returns information about the given entry in the range with the given name.

func (*Client) List

func (c *Client) List(ctx context.Context) ([]string, error)

List returns the names of all known ranges.

func (*Client) Next

func (c *Client) Next(ctx context.Context, name string, m *irange.Metadata) (irange.Entry, error)

Next returns the next entry in the range with the given name, or ErrEmpty if no such entry exists. The caller identifies itself to the storage engine via m.

func (*Client) Requeue

func (c *Client) Requeue(ctx context.Context, id irange.ID) error

Requeue indicates that the entry with the given ID should be requeued, without incrementing the number of failures.

func (*Client) RequeueActive added in v0.0.11

func (c *Client) RequeueActive(ctx context.Context, name string) error

RequeueActive requeues all active entries in the range with the given name

func (*Client) RequeueFailed added in v0.0.11

func (c *Client) RequeueFailed(ctx context.Context, name string) error

RequeueFailed requeues all failed entries in the range with the given name

func (*Client) RequeueSucceeded added in v0.0.11

func (c *Client) RequeueSucceeded(ctx context.Context, name string) error

RequeueSucceeded requeues all entries that have succeeded in the range with the given name

func (*Client) Status

func (c *Client) Status(ctx context.Context, name string) (irange.Status, error)

Status returns the status of the range with the given name.

func (*Client) Success

func (c *Client) Success(ctx context.Context, id irange.ID) error

Success indicates that the entry with the given ID has succeeded.

type ClientConfig

type ClientConfig struct {
	Address     *address.Address // The address to connect to
	SSLDisabled bool             // Disable SSL?
	SSLCert     []byte           // The SSL certificate (if any)
}

ClientConfig describes the configuration options we allow a user to set on a client connection.

func DefaultConfig

func DefaultConfig() *ClientConfig

DefaultConfig returns a new client configuration initialised with the default values.

The initial default value for the host will be read from the environment variable

PCAS_RANGEDB_ADDRESS = "hostname[:port]" or "ws://host/path"

on package init.

func SetDefaultConfig

func SetDefaultConfig(c *ClientConfig) *ClientConfig

SetDefaultConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultConfig.

func (*ClientConfig) Copy

func (c *ClientConfig) Copy() *ClientConfig

Copy returns a copy of the configuration.

func (*ClientConfig) Hash added in v0.0.13

func (c *ClientConfig) Hash() uint32

Hash returns a hash for the configuration.

func (*ClientConfig) URI

func (c *ClientConfig) URI() string

URI returns the URI connection string.

Note that the returned string may differ slightly from the value returned c.Address.URI(). For example, if c.Address omits a port number, an appropriate default port number is used here.

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

Validate validates the client configuration, returning an error if there's a problem.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets options on an irange server.

func SSLCertAndKey

func SSLCertAndKey(crt []byte, key []byte) Option

SSLCertAndKey adds the given SSL public certificate and private key to the server.

func WithStorage

func WithStorage(engine irange.Storage) Option

WithStorage sets the underlying storage engine for the server.

type Server

Server handles client communication.

func NewServer

func NewServer(options ...Option) (*Server, error)

NewServer returns a new rangedb server.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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