Documentation ¶
Index ¶
- type APIMetrics
- type Config
- type Endpoints
- type Gauge
- type GaugeVec
- type Histogram
- type HistogramVec
- type OS
- type Option
- type Peer
- type SchedulerTask
- type Service
- func (s *Service) APIMetrics() APIMetrics
- func (s *Service) ClientCerts() []x509.Certificate
- func (s *Service) ClusterCerts() []x509.Certificate
- func (s *Service) Endpoints() Endpoints
- func (s *Service) Init(configs ...Config) error
- func (s *Service) Kill()
- func (s *Service) Register(tasks []SchedulerTask) error
- func (s *Service) RegisterChan() <-chan struct{}
- func (s *Service) SetupChan() <-chan struct{}
- func (s *Service) ShutdownChan() <-chan struct{}
- func (s *Service) Stop() error
- func (s *Service) UnsafeShutdown()
- func (s *Service) Version() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIMetrics ¶
type APIMetrics struct {
// contains filtered or unexported fields
}
func NewAPIMetrics ¶
func NewAPIMetrics(apiDuration HistogramVec, connectedClients GaugeVec) APIMetrics
NewAPIMetrics creates a new APIMetrics with sane defaults
func (APIMetrics) APIDuration ¶
func (a APIMetrics) APIDuration() HistogramVec
APIDuration returns the HistogramVec for collecting api duration metrics
func (APIMetrics) ConnectedClients ¶
func (a APIMetrics) ConnectedClients() GaugeVec
ConnectedClients returns the GaugeVec for collecting the number of connected client metrics
type Config ¶
type Config func(*config)
Config defines a option for generating a filesystem config
func WithAdvertiseAddrPort ¶
WithAdvertiseAddrPort adds a AdvertiseAddr and AdvertisePort to the configuration
func WithBindAddrPort ¶
WithBindAddrPort adds a BindAddr and BindPort to the configuration
func WithDaemon ¶
WithDaemon adds a DaemonAddress and DaemonNonce to the configuration
type Endpoints ¶
type Endpoints interface { // Up brings up all configured endpoints and starts accepting HTTP requests. Up() error // Down brings down all endpoints and stops serving HTTP requests. Down() error // NetworkAddress returns the network address of the network endpoint, or an // empty string if there's no network endpoint NetworkAddress() string // NetworkPrivateKey returns the private key of the TLS certificate used by the // network endpoint. NetworkPrivateKey() []byte // NetworkCert returns the full TLS certificate information for this endpoint. NetworkCert() *cert.Info // NetworkPublicKey returns the public key of the TLS certificate used by the // network endpoint. NetworkPublicKey() []byte // NetworkUpdateAddress updates the address for the network endpoint, // shutting it down and restarting it. NetworkUpdateAddress(string) error // PprofUpdateAddress updates the address for the pprof endpoint, shutting // it down and restarting it. PprofUpdateAddress(string) error // NetworkUpdateCert updates the cert for the network endpoint, // shutting it down and restarting it. NetworkUpdateCert(*cert.Info) error }
Endpoints are in charge of bringing up and down the HTTP endpoints for serving the RESTful API.
type Gauge ¶
type Gauge interface { // Inc increments the Gauge by 1. Use Add to increment it by arbitrary // values. Inc() }
Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down.
type GaugeVec ¶
type GaugeVec interface { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. By not returning an // error, WithLabelValues allows shortcuts like // myVec.WithLabelValues("404", "GET").Add(42) WithLabelValues(lvs ...string) Gauge }
GaugeVec is a Collector that bundles a set of Gauges that all share the same Desc, but have different values for their variable labels.
type Histogram ¶
type Histogram interface { // Observe adds a single observation to the histogram. Observe(float64) }
A Histogram counts individual observations from an event or sample stream in configurable buckets. Similar to a summary, it also provides a sum of observations and an observation count.
type HistogramVec ¶
type HistogramVec interface { // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. By not returning an // error, WithLabelValues allows shortcuts like // myVec.WithLabelValues("404", "GET").Observe(42.21) WithLabelValues(lvs ...string) Histogram }
HistogramVec is a Collector that bundles a set of Histograms that all share the same Desc, but have different values for their variable labels.
type OS ¶
type OS interface { // Init our internal data structures. Init(fsys.FileSystem) error // 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 Connect to customize the resulting instance.
func WithFileSystem ¶
func WithFileSystem(fileSystem fsys.FileSystem) Option
WithFileSystem sets the fileSystem on the options
func WithLogger ¶
WithLogger sets the logger on the option
type Peer ¶
type Peer interface { // AddHandler attaches a event listener to all the members events // and broadcasts the event to the handler. AddHandler(members.Handler) // RemoveHandler removes the event listener. RemoveHandler(members.Handler) // Join the cluster Join() (int, error) // Leave the cluster. Leave() error // Name returns unique ID of this peer in the cluster. Name() string // Address returns host:port of this peer in the cluster. Address() string // ClusterSize returns the total size of the cluster from this node's // perspective. ClusterSize() int // State returns a JSON-serializable dump of cluster state. // Useful for debug. State() map[string]interface{} // Current API host:ports for the given type of node. // Bool defines if you want to include the current local node. Current(members.PeerType, bool) ([]string, error) // Close and shutdown the peer Close() }
Peer represents the node with in the cluster.
type SchedulerTask ¶
type SchedulerTask interface { // Run setups up the given schedule Run() (task.Func, task.Schedule) }
SchedulerTask defines a task that can be run repeatedly
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service defines a controller for managing service discovery
func NewService ¶
func NewService( certInfo *cert.Info, clientCerts, clusterCerts []x509.Certificate, config *clusterconfig.ReadOnlyConfig, version string, networkAddress, debugAddress string, apiMetrics APIMetrics, apiServices, apiInternalServices []api.Service, daemonAddress, daemonNonce string, options ...Option, ) *Service
NewService creates a new service with sane defaults
func (*Service) APIMetrics ¶
func (s *Service) APIMetrics() APIMetrics
APIMetrics returns the metrics for recording metric changes
func (*Service) ClientCerts ¶
func (s *Service) ClientCerts() []x509.Certificate
ClientCerts returns the certificates used locally
func (*Service) ClusterCerts ¶
func (s *Service) ClusterCerts() []x509.Certificate
ClusterCerts returns the network certificates used for the cluster.
func (*Service) Register ¶
func (s *Service) Register(tasks []SchedulerTask) error
Register tasks or system services for the service
func (*Service) RegisterChan ¶
func (s *Service) RegisterChan() <-chan struct{}
RegisterChan returns a channel that blocks until all the registered tasks have happened for the Service
func (*Service) SetupChan ¶
func (s *Service) SetupChan() <-chan struct{}
SetupChan returns a channel that blocks until setup has happened from the Service
func (*Service) ShutdownChan ¶
func (s *Service) ShutdownChan() <-chan struct{}
ShutdownChan returns a channel that blocks until shutdown has happened from the Service.
func (*Service) UnsafeShutdown ¶
func (s *Service) UnsafeShutdown()
UnsafeShutdown forces an automatic shutdown of the Daemon