kvdb

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 38 Imported by: 7

Documentation

Index

Constants

View Source
const (
	DefaultTCPPort = 12356
	DefaultWSPort  = 80
)

The default ports that kvdb listens on.

View Source
const (
	DefaultMaxMessageSize  = 16 * 1024 * 1024 // 16Mb
	DefaultReadBufferSize  = 512 * 1024       // 512Kb
	DefaultWriteBufferSize = 512 * 1024       // 512Kb
	DefaultInsertCapacity  = 128
)

The default kvdb server values.

Variables

View Source
var ErrNilConfiguration = errors.New("illegal nil configuration data")

ErrNilConfiguration is returned when a ClientConfig fails to validate.

Functions

func AreEqual added in v0.1.37

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

AreEqual returns true iff the two configurations are equal.

func Open added in v0.1.37

Open opens a connection to kvdb.

Types

type ClientConfig

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

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_KVDB_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.1.37

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 a kvdb server.

func Connection added in v0.1.37

func Connection(c keyvalue.Connection) Option

Connection sets the connection for the server.

func InsertCapacity added in v0.1.36

func InsertCapacity(n int) Option

InsertCapacity sets the maximum number of simultaneous inserts. Set to 0 to allow an unlimited number of inserts.

func MaxMessageSize

func MaxMessageSize(size int) Option

MaxMessageSize sets the maximum message size (in bytes) the server can receive.

func ReadBufferSize

func ReadBufferSize(size int) Option

ReadBufferSize sets the size of the read buffer (in bytes).

func SSLCertAndKey

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

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

func WriteBufferSize

func WriteBufferSize(size int) Option

WriteBufferSize sets the size of the write buffer (in bytes).

type Server

Server handles client communication.

func New

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

New returns a new kvdb server.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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