Documentation ¶
Index ¶
- type Hooks
- type InternalState
- func (s *InternalState) Address() *api.URL
- func (s *InternalState) Cluster(isNotification bool) (client.Cluster, error)
- func (s *InternalState) ClusterCert() *shared.CertInfo
- func (s *InternalState) Database() db.DB
- func (s *InternalState) ExtensionServers() []string
- func (s *InternalState) FileSystem() *sys.OS
- func (s *InternalState) HasExtension(ext string) bool
- func (s *InternalState) Leader() (*client.Client, error)
- func (s *InternalState) Name() string
- func (s *InternalState) Remotes() *trust.Remotes
- func (s *InternalState) ServerCert() *shared.CertInfo
- func (s *InternalState) Version() string
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hooks ¶
type Hooks struct { // PreBootstrap is run before the daemon is initialized and bootstrapped. PreBootstrap func(ctx context.Context, s State, initConfig map[string]string) error // PostBootstrap is run after the daemon is initialized and bootstrapped. PostBootstrap func(ctx context.Context, s State, initConfig map[string]string) error // OnStart is run after the daemon is started. Its context will not be cancelled until the daemon is shutting down. OnStart func(ctx context.Context, s State) error // PostJoin is run after the daemon is initialized, joined the cluster and existing members triggered // their 'OnNewMember' hooks. PostJoin func(ctx context.Context, s State, initConfig map[string]string) error // PreJoin is run after the daemon is initialized and joined the cluster but before existing members triggered // their 'OnNewMember' hooks. PreJoin func(ctx context.Context, s State, initConfig map[string]string) error // PreRemove is run on a cluster member just before it is removed from the cluster. PreRemove func(ctx context.Context, s State, force bool) error // PostRemove is run on all other peers after one is removed from the cluster. PostRemove func(ctx context.Context, s State, force bool) error // OnHeartbeat is run after a successful heartbeat round. OnHeartbeat func(ctx context.Context, s State) error // OnNewMember is run on each peer after a new cluster member has joined and executed their 'PreJoin' hook. OnNewMember func(ctx context.Context, s State, newMember types.ClusterMemberLocal) error // OnDaemonConfigUpdate is a post-action hook that is run on all cluster members when any cluster member receives a local configuration update. OnDaemonConfigUpdate func(ctx context.Context, s State, config types.DaemonConfig) error }
Hooks holds customizable functions that can be called at varying points by the daemon to. integrate with other tools.
type InternalState ¶
type InternalState struct { // Context. Context context.Context // Ready channel. ReadyCh chan struct{} // ShutdownDoneCh receives the result of the d.Stop() function and tells the daemon to end. ShutdownDoneCh chan error // Endpoints manages the network and unix socket listeners. Endpoints *endpoints.Endpoints // Local daemon's config. LocalConfig func() *internalConfig.DaemonConfig // Initialize APIs and bootstrap/join database. StartAPI func(ctx context.Context, bootstrap bool, initConfig map[string]string, newConfig *trust.Location, joinAddresses ...string) error // Update the additional listeners. UpdateServers func() error // ReloadCert reloads the given keypair from the state directory. ReloadCert func(name types.CertificateName) error // StopListeners stops the network listeners and the fsnotify listener. StopListeners func() error // Stop fully stops the daemon, its database, and all listeners. Stop func() (exit func(), stopErr error) // Runtime extensions. Extensions extensions.Extensions // Hooks contain external implementations that are triggered by specific cluster actions. Hooks *Hooks InternalFileSystem func() *sys.OS InternalAddress func() *api.URL InternalName func() string InternalVersion func() string InternalServerCert func() *shared.CertInfo InternalClusterCert func() *shared.CertInfo InternalDatabase *db.DqliteDB InternalRemotes func() *trust.Remotes InternalExtensionServers func() []string }
InternalState is a gateway to the stateful components of the microcluster daemon.
func ToInternal ¶
func ToInternal(s State) (*InternalState, error)
ToInternal returns the underlying InternalState from the exposed State interface.
func (*InternalState) Address ¶
func (s *InternalState) Address() *api.URL
Address returns the core microcluster listen address.
func (*InternalState) Cluster ¶
func (s *InternalState) Cluster(isNotification bool) (client.Cluster, error)
Cluster returns a client for every member of a cluster, except this one. All requests made by the client will have the UserAgentNotifier header set if isNotification is true.
func (*InternalState) ClusterCert ¶
func (s *InternalState) ClusterCert() *shared.CertInfo
ClusterCert returns the keypair identifying the cluster.
func (*InternalState) Database ¶
func (s *InternalState) Database() db.DB
Database allows access to the dqlite database.
func (*InternalState) ExtensionServers ¶
func (s *InternalState) ExtensionServers() []string
ExtensionServers returns an immutable list of the daemon's additional listeners.
func (*InternalState) FileSystem ¶
func (s *InternalState) FileSystem() *sys.OS
FileSystem can be used to inspect the microcluster filesystem.
func (*InternalState) HasExtension ¶
func (s *InternalState) HasExtension(ext string) bool
HasExtension returns whether the given API extension is supported.
func (*InternalState) Leader ¶
func (s *InternalState) Leader() (*client.Client, error)
Leader returns a client connected to the dqlite leader.
func (*InternalState) Name ¶
func (s *InternalState) Name() string
Name returns the cluster name for the local system.
func (*InternalState) Remotes ¶
func (s *InternalState) Remotes() *trust.Remotes
Remotes returns the local record of cluster members in the truststore.
func (*InternalState) ServerCert ¶
func (s *InternalState) ServerCert() *shared.CertInfo
ServerCert returns the keypair identifying the local system.
func (*InternalState) Version ¶
func (s *InternalState) Version() string
Version is provided by the MicroCluster consumer. The daemon includes it in its /cluster/1.0 response.
type State ¶
type State interface { // FileSystem structure. FileSystem() *sys.OS // Listen Address. Address() *api.URL // Name of the cluster member. Name() string // Version is provided by the MicroCluster consumer. Version() string // Server certificate is used for server-to-server connection. ServerCert() *shared.CertInfo // Cluster certificate is used for downstream connections within a cluster. ClusterCert() *shared.CertInfo // Database. Database() db.DB // Local truststore access. Remotes() *trust.Remotes // Cluster returns a client to every cluster member according to dqlite. Cluster(isNotification bool) (client.Cluster, error) // Leader returns a client to the dqlite cluster leader. Leader() (*client.Client, error) // HasExtension returns whether the given API extension is supported. HasExtension(ext string) bool // ExtensionServers returns an immutable list of the daemon's additional listeners. ExtensionServers() []string }
State exposes the internal daemon state for use with extended API handlers.