client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogDebug = logging.Debug
	LogInfo  = logging.Info
	LogWarn  = logging.Warn
	LogError = logging.Error
)

Available logging levels.

Variables

View Source
var NewInmemNodeStore = protocol.NewInmemNodeStore

NewInmemNodeStore creates NodeStore which stores its data in-memory.

Functions

func DefaultDialFunc

func DefaultDialFunc(ctx context.Context, address string) (net.Conn, error)

func DefaultLogFunc

func DefaultLogFunc(l LogLevel, format string, a ...interface{})

DefaultLogFunc emits messages using the stdlib's logger.

Types

type Client

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

Client speaks the dqlite wire protocol.

func FindLeader

func FindLeader(ctx context.Context, store NodeStore, options ...Option) (*Client, error)

FindLeader returns a Client connected to the current cluster leader, if any.

func New

func New(ctx context.Context, address string, options ...Option) (*Client, error)

New creates a new client connected to the dqlite node with the given address.

func (*Client) Add

func (c *Client) Add(ctx context.Context, node NodeInfo) error

Add a node to a cluster.

func (*Client) Close

func (c *Client) Close() error

Close the client.

func (*Client) Cluster

func (c *Client) Cluster(ctx context.Context) ([]NodeInfo, error)

Cluster returns information about all nodes in the cluster.

func (*Client) Dump

func (c *Client) Dump(ctx context.Context, dbname string) ([]File, error)

Dump the content of the database with the given name. Two files will be returned, the first is the main database file (which has the same name as the database), the second is the WAL file (which has the same name as the database plus the suffix "-wal").

func (*Client) Leader

func (c *Client) Leader(ctx context.Context) (*NodeInfo, error)

Leader returns information about the current leader, if any.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, id uint64) error

Remove a node from the cluster.

type DatabaseNodeStore

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

DatabaseNodeStore persists a list addresses of dqlite nodes in a SQL table.

func DefaultNodeStore

func DefaultNodeStore(filename string) (*DatabaseNodeStore, error)

DefaultNodeStore creates a new NodeStore using the given filename to open a SQLite database, with default names for the schema, table and column parameters.

It also creates the table if it doesn't exist yet.

func NewNodeStore

func NewNodeStore(db *sql.DB, schema, table, column string) *DatabaseNodeStore

NewNodeStore creates a new NodeStore.

func (*DatabaseNodeStore) Get

func (d *DatabaseNodeStore) Get(ctx context.Context) ([]NodeInfo, error)

Get the current servers.

func (*DatabaseNodeStore) Set

func (d *DatabaseNodeStore) Set(ctx context.Context, servers []NodeInfo) error

Set the servers addresses.

type DialFunc

type DialFunc = protocol.DialFunc

DialFunc is a function that can be used to establish a network connection.

type File

type File struct {
	Name string
	Data []byte
}

File holds the content of a single database file.

type InmemNodeStore

type InmemNodeStore = protocol.InmemNodeStore

InmemNodeStore keeps the list of target dqlite nodes in memory.

type LogFunc

type LogFunc = logging.Func

LogFunc is a function that can be used for logging.

type LogLevel

type LogLevel = logging.Level

LogLevel defines the logging level.

type NodeInfo

type NodeInfo = protocol.NodeInfo

NodeInfo holds information about a single server.

type NodeStore

type NodeStore = protocol.NodeStore

NodeStore is used by a dqlite client to get an initial list of candidate dqlite nodes that it can dial in order to find a leader dqlite node to use.

type Option

type Option func(*options)

Option that can be used to tweak client parameters.

func WithDialFunc

func WithDialFunc(dial DialFunc) Option

WithDialFunc sets a custom dial function for creating the client network connection.

func WithLogFunc

func WithLogFunc(log LogFunc) Option

WithLogFunc sets a custom log function. connection.

Jump to

Keyboard shortcuts

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