node

package
v0.0.0-...-d2438c5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigSchema = config.Schema{

	"core.https_address": {},

	"core.debug_address": {},
}

ConfigSchema defines available server configuration keys.

Functions

func DebugAddress

func DebugAddress(node Node, schema config.Schema) (string, error)

DebugAddress is a convenience for loading the node configuration and returning the value of core.debug_address.

func DetermineRaftNode

func DetermineRaftNode(tx Tx, schema config.Schema) (*db.RaftNode, error)

DetermineRaftNode figures out what raft node ID and address we have, if any.

This decision is based on the values of the core.https_address config key and on the rows in the raft_nodes table, both stored in the node-level SQLite database.

The following rules are applied:

  • If no core.https_address config key is set, this is a non-clustered node and the returned RaftNode will have ID 1 but no address, to signal that the node should setup an in-memory raft cluster where the node itself is the only member and leader.
  • If core.https_address config key is set, but there is no row in the raft_nodes table, this is a non-clustered node as well, and same behavior as the previous case applies.
  • If core.https_address config key is set and there is at least one row in the raft_nodes table, then this node is considered a raft node if core.https_address matches one of the rows in raft_nodes. In that case, the matching db.RaftNode row is returned, otherwise nil.

func HTTPSAddress

func HTTPSAddress(node Node, schema config.Schema) (string, error)

HTTPSAddress is a convenience for loading the node configuration and returning the value of core.https_address.

func PatchConfig

func PatchConfig(node Node, key string, value interface{}, schema config.Schema) error

PatchConfig is a convenience for patching the node configuration

Types

type Config

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

Config holds node-local configuration values for a certain instance

func ConfigLoad

func ConfigLoad(tx Tx, schema config.Schema) (*Config, error)

ConfigLoad loads a new Config object with the current node-local configuration values fetched from the database. An optional list of config value triggers can be passed, each config key must have at most one trigger.

func NewConfig

func NewConfig(options ...Option) *Config

NewConfig creates a Config with sane defaults.

func (*Config) DebugAddress

func (c *Config) DebugAddress() (string, error)

DebugAddress returns the address and port to setup the pprof listener on

func (*Config) Dump

func (c *Config) Dump() (map[string]interface{}, error)

Dump current configuration keys and their values. Keys with values matching their defaults are omitted.

func (*Config) HTTPSAddress

func (c *Config) HTTPSAddress() (string, error)

HTTPSAddress returns the address and port this node should expose its API to, if any.

func (*Config) Patch

func (c *Config) Patch(patch map[string]interface{}) (map[string]string, error)

Patch changes only the configuration keys in the given map.

func (*Config) Replace

func (c *Config) Replace(values map[string]interface{}) (map[string]string, error)

Replace the current configuration with the given values.

type Node

type Node interface {
	db.NodeTransactioner
}

Node mediates access to the data stored in the node-local SQLite database.

type Option

type Option func(*options)

Option to be passed to New to customize the resulting instance.

func Map

func Map(configMap config.Map) Option

Map sets the configMap on the options

func NodeTx

func NodeTx(nodeTx Tx) Option

NodeTx sets the nodeTx on the options

type Tx

type Tx interface {

	// Config fetches all node-level config keys.
	Config() (map[string]string, error)

	// UpdateConfig updates the given node-level configuration keys in the
	// config table. Config keys set to empty values will be deleted.
	UpdateConfig(map[string]string) error

	// RaftNodes returns information about all nodes that are members of the
	// dqlite Raft cluster (possibly including the local node). If this
	// instance is not running in clustered mode, an empty list is returned.
	RaftNodes() ([]db.RaftNode, error)
}

Tx models a single interaction with a node-local database.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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