Documentation ¶
Index ¶
Constants ¶
const BootstrapID = 0x2dc171858c3155be
BootstrapID is a magic ID that should be used for the fist node in a cluster. Alternatively ID 1 can be used as well.
Variables ¶
This section is empty.
Functions ¶
func ConfigMultiThread ¶
func ConfigMultiThread() error
ConfigMultiThread sets the threading mode of SQLite to Multi-thread.
By default go-cowsql configures SQLite to Single-thread mode, because the cowsql engine itself is single-threaded, and enabling Multi-thread or Serialized modes would incur in a performance penality.
If your Go process also uses SQLite directly (e.g. using the github.com/mattn/go-sqlite3 bindings) you might need to switch to Multi-thread mode in order to be thread-safe.
IMPORTANT: It's possible to successfully change SQLite's threading mode only if no SQLite APIs have been invoked yet (e.g. no database has been opened yet). Therefore you'll typically want to call ConfigMultiThread() very early in your process setup. Alternatively you can set the GO_COWSQL_MULTITHREAD environment variable to 1 at process startup, in order to prevent go-cowsql from setting Single-thread mode at all.
func GenerateID ¶
GenerateID generates a unique ID for a new node, based on a hash of its address and the current time.
func ReconfigureMembership ¶
ReconfigureMembership can be used to recover a cluster whose majority of nodes have died, and therefore has become unavailable.
It forces appending a new configuration to the raft log stored in the given directory, effectively replacing the current configuration.
func ReconfigureMembershipExt ¶
ReconfigureMembershipExt can be used to recover a cluster whose majority of nodes have died, and therefore has become unavailable.
It forces appending a new configuration to the raft log stored in the given directory, effectively replacing the current configuration. In comparision with ReconfigureMembership, this function takes the node role into account and makes use of a cowsql API that supports extending the NodeInfo struct.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node runs a cowsql node.
func (*Node) BindAddress ¶
BindAddress returns the network address the node is listening to.
type Option ¶
type Option func(*options)
Option can be used to tweak node parameters.
func WithAutoRecovery ¶ added in v1.21.0
WithAutoRecovery enables or disables auto-recovery of persisted data at startup for this node.
When auto-recovery is enabled, raft snapshots and segment files may be deleted at startup if they are determined to be corrupt. This helps the startup process to succeed in more cases, but can lead to data loss.
Auto-recovery is enabled by default.
func WithBindAddress ¶
WithBindAddress sets a custom bind address for the server.
func WithDialFunc ¶
WithDialFunc sets a custom dial function for the server.
func WithFailureDomain ¶
WithFailureDomain sets the code of the failure domain the node belongs to.
func WithNetworkLatency ¶
WithNetworkLatency sets the average one-way network latency.
func WithSnapshotParams ¶
func WithSnapshotParams(params SnapshotParams) Option
WithSnapshotParams sets the snapshot parameters of the node.
type SnapshotParams ¶
type SnapshotParams = bindings.SnapshotParams
SnapshotParams exposes bindings.SnapshotParams. Used for setting cowsql's snapshot parameters. SnapshotParams.Threshold controls after how many raft log entries a snapshot is taken. The higher this number, the lower the frequency of the snapshots. SnapshotParams.Trailing controls how many raft log entries are retained after taking a snapshot.