Documentation
¶
Index ¶
- type InternalState
- func (s *InternalState) Address() *url.URL
- func (s *InternalState) CheckMembershipConsistency(ctx context.Context) error
- func (s *InternalState) Cluster(isNotification bool) (types.Clients, error)
- func (s *InternalState) ClusterCert() *shared.CertInfo
- func (s *InternalState) Connect() types.Connector
- func (s *InternalState) Database() types.DB
- func (s *InternalState) ExtensionServers() []string
- func (s *InternalState) FileSystem() types.OS
- func (s *InternalState) HasExtension(ext string) bool
- func (s *InternalState) Leader(isNotification bool) (types.Client, error)
- func (s *InternalState) Member(url *url.URL, isNotification bool, cert *x509.Certificate) (types.Client, error)
- func (s *InternalState) Name() string
- func (s *InternalState) RandomMember(isNotification bool) (types.Client, error)
- func (s *InternalState) ServerCert() *shared.CertInfo
- func (s *InternalState) Truststore() types.Store
- func (s *InternalState) Version() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
// SetConfig Applies and commits to memory the supplied daemon configuration.
SetConfig func(types.Location) error
// Initialize APIs and bootstrap/join database.
StartAPI func(ctx context.Context, bootstrap bool, initConfig map[string]string, 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 servers, and the fsnotify listener.
StopListeners func() error
// Stop fully stops the daemon, its database, all listeners, and all servers.
Stop func() (exit func(), stopErr error)
// Runtime extensions.
Extensions types.Extensions
// Hooks contain external implementations that are triggered by specific cluster actions.
Hooks *types.Hooks
InternalFileSystem func() types.OS
InternalAddress func() *url.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 types.State) (*InternalState, error)
ToInternal returns the underlying InternalState from the exposed State interface.
func (*InternalState) Address ¶
func (s *InternalState) Address() *url.URL
Address returns the core microcluster listen address.
func (*InternalState) CheckMembershipConsistency ¶
func (s *InternalState) CheckMembershipConsistency(ctx context.Context) error
CheckMembershipConsistency verifies that core_cluster_members, truststore, and dqlite all have consistent membership information. This should be called before any member add/remove operations or join token generation to ensure the cluster is in a healthy state.
func (*InternalState) Cluster ¶
func (s *InternalState) Cluster(isNotification bool) (types.Clients, 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. Uses the trust store instead of database for better fault tolerance - trust store is updated on heartbeats and shouldn't contain crashed nodes.
func (*InternalState) ClusterCert ¶
func (s *InternalState) ClusterCert() *shared.CertInfo
ClusterCert returns the keypair identifying the cluster.
func (*InternalState) Connect ¶
func (s *InternalState) Connect() types.Connector
func (*InternalState) Database ¶
func (s *InternalState) Database() types.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() types.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(isNotification bool) (types.Client, error)
Leader returns a client connected to the dqlite leader.
func (*InternalState) Member ¶
func (s *InternalState) Member(url *url.URL, isNotification bool, cert *x509.Certificate) (types.Client, error)
Member returns a client to a specific cluster member based on the given url. An additional certificate can be provided to verify the remote endpoint.
func (*InternalState) Name ¶
func (s *InternalState) Name() string
Name returns the cluster name for the local system.
func (*InternalState) RandomMember ¶
func (s *InternalState) RandomMember(isNotification bool) (types.Client, error)
RandomMember returns a client for a random cluster member.
func (*InternalState) ServerCert ¶
func (s *InternalState) ServerCert() *shared.CertInfo
ServerCert returns the keypair identifying the local system.
func (*InternalState) Truststore ¶
func (s *InternalState) Truststore() types.Store
Truststore returns the local record of cluster members in the truststore.
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.