Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultDialFunc(ctx context.Context, address string) (net.Conn, error)
- func DefaultLogFunc(l LogLevel, format string, a ...interface{})
- type Client
- func (c *Client) Add(ctx context.Context, node NodeInfo) error
- func (c *Client) Close() error
- func (c *Client) Cluster(ctx context.Context) ([]NodeInfo, error)
- func (c *Client) Dump(ctx context.Context, dbname string) ([]File, error)
- func (c *Client) Leader(ctx context.Context) (*NodeInfo, error)
- func (c *Client) Remove(ctx context.Context, id uint64) error
- type DatabaseNodeStore
- type DialFunc
- type File
- type InmemNodeStore
- type LogFunc
- type LogLevel
- type NodeInfo
- type NodeStore
- type Option
Constants ¶
const ( LogDebug = logging.Debug LogInfo = logging.Info LogWarn = logging.Warn LogError = logging.Error )
Available logging levels.
Variables ¶
var NewInmemNodeStore = protocol.NewInmemNodeStore
NewInmemNodeStore creates NodeStore which stores its data in-memory.
Functions ¶
func DefaultLogFunc ¶
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 ¶
FindLeader returns a Client connected to the current cluster leader, if any.
func (*Client) Dump ¶
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").
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.
type InmemNodeStore ¶
type InmemNodeStore = protocol.InmemNodeStore
InmemNodeStore keeps the list of target dqlite nodes in memory.
type 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 ¶
WithDialFunc sets a custom dial function for creating the client network connection.
func WithLogFunc ¶
WithLogFunc sets a custom log function. connection.