state

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnsafeSetCluster

func UnsafeSetCluster(state *State, cluster Cluster)

UnsafeSetCluster modifies the underlying state to set the cluster upon the state

Types

type Cluster

type Cluster interface {
	database.DBAccessor
	db.ClusterOpener
	db.ClusterExclusiveLocker
	db.ClusterTransactioner

	// NodeID sets the the node NodeID associated with this cluster instance. It's used for
	// backward-compatibility of all db-related APIs that were written before
	// clustering and don't accept a node NodeID, so in those cases we automatically
	// use this value as implicit node NodeID.
	NodeID(int64)

	// SchemaVersion returns the underlying schema version for the cluster
	SchemaVersion() int

	// Close the database facade.
	Close() error
}

Cluster mediates access to data stored in the cluster dqlite database.

type Node

type Node interface {
	database.DBAccessor
	db.NodeOpener
	db.NodeTransactioner

	// Dir returns the directory of the underlying database file.
	Dir() string

	// Close the database facade.
	Close() error
}

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

type OS

type OS interface {

	// LocalDatabasePath returns the path of the local database file.
	LocalDatabasePath() string

	// GlobalDatabaseDir returns the path of the global database directory.
	GlobalDatabaseDir() string

	// GlobalDatabasePath returns the path of the global database SQLite file
	// managed by dqlite.
	GlobalDatabasePath() string

	// VarDir represents the Data directory (e.g. /var/lib/therm/).
	VarDir() string

	// Hostname returns the host name reported by the kernel.
	Hostname() (string, error)

	// HostNames will generate a list of names for which the certificate will be
	// valid.
	// This will include the hostname and ip address
	HostNames() ([]string, error)

	// User returns the current user.
	User() (*user.User, error)
}

OS is a high-level facade for accessing all operating-system level functionality that therm uses.

type Option

type Option func(*options)

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

func WithCluster

func WithCluster(cluster Cluster) Option

WithCluster sets the cluster on the options

func WithNode

func WithNode(node Node) Option

WithNode sets the node on the options

func WithOS

func WithOS(os OS) Option

WithOS sets the os on the options

type State

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

State is a gateway to the two main stateful components, the database and the operating system. It's typically used by model entities such as containers, volumes, etc. in order to perform changes.

func NewState

func NewState(options ...Option) *State

NewState returns a new State object with the given database and operating system components.

func (*State) Cluster

func (s *State) Cluster() Cluster

Cluster returns the underlying Cluster

func (*State) Node

func (s *State) Node() Node

Node returns the underlying Node

func (*State) OS

func (s *State) OS() OS

OS returns the underlying OS values

Jump to

Keyboard shortcuts

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