state

package
v0.0.0-...-5fbd3a7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LeaderInfo

type LeaderInfo struct {
	// Clustered is true if the server is clustered and false otherwise.
	Clustered bool

	// Leader is true if the server is the raft leader or if the server is not clustered, and false otherwise.
	Leader bool

	// Address is the address of the leader. It is not set if the server is not clustered.
	Address string
}

LeaderInfo represents information regarding cluster member leadership.

type State

type State struct {
	// Shutdown Context
	ShutdownCtx context.Context

	// Databases
	DB *db.DB

	// MAAS server
	MAAS *maas.Controller

	// BGP server
	BGP *bgp.Server

	// DNS server
	DNS *dns.Server

	// OS access
	OS    *sys.OS
	Proxy func(req *http.Request) (*url.URL, error)

	// LXD server
	Endpoints *endpoints.Endpoints

	// Event server
	DevlxdEvents *events.DevLXDServer
	Events       *events.Server

	// Firewall instance
	Firewall firewall.Firewall

	// Server certificate
	ServerCert func() *shared.CertInfo

	// UpdateIdentityCache refreshes the local cache of identities.
	// This should be called whenever an identity is added, modified, or removed.
	// The cache is also refreshed on dqlite heartbeat to synchronise with other members.
	UpdateIdentityCache func()

	// Available instance types based on operational drivers.
	InstanceTypes map[instancetype.Type]error

	// Filesystem monitor
	DevMonitor fsmonitor.FSMonitor

	// Global configuration
	GlobalConfig *clusterConfig.Config

	// Local configuration
	LocalConfig *node.Config

	// Local server name.
	ServerName string

	// Whether the server is clustered.
	ServerClustered bool

	// Whether we are the leader and the leader address if not.
	LeaderInfo func() (*LeaderInfo, error)

	// Local server UUID.
	ServerUUID string

	// Local server start time.
	StartTime time.Time

	// Authorizer.
	Authorizer auth.Authorizer
}

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

func NewTestState

func NewTestState(t *testing.T) (*State, func())

NewTestState returns a State object initialized with testable instances of the node/cluster databases and of the OS facade.

Return the newly created State object, along with a function that can be used for cleaning it up.

Jump to

Keyboard shortcuts

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