Documentation
¶
Overview ¶
Package core implements the basic logic of health checking virtual and real servers.
Index ¶
- func JSONConfigLoader(path string, config *Config) error
- func KeepalivedConfigLoader(path string, config *Config) error
- type Config
- type ConfigFormat
- type ConfigLoader
- type Core
- type Manager
- type ManagerConfig
- type Metrics
- func (m *Metrics) DeleteService(serviceLabels metrics.Labels)
- func (m *Metrics) Reals() metrics.Gauge
- func (m *Metrics) RealsEnabled() metrics.Gauge
- func (m *Metrics) RealsEnabledForService(serviceLabels metrics.Labels) metrics.Gauge
- func (m *Metrics) RealsErrorsForService(serviceLabels metrics.Labels) metrics.CounterVec
- func (m *Metrics) RealsForService(serviceLabels metrics.Labels) metrics.Gauge
- func (m *Metrics) RealsResponseTimeForService(serviceLabels metrics.Labels) metrics.Histogram
- func (m *Metrics) RealsTrasitionPeriodForService(serviceLabels metrics.Labels) metrics.Histogram
- type ServicesConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONConfigLoader ¶
JSONConfigLoader is intended to load a configuration from a JSON file. Currently, it is not implemented and will panic if called.
func KeepalivedConfigLoader ¶
KeepalivedConfigLoader loads a configuration from a keepalived format file.
Types ¶
type Config ¶
type Config struct {
// List of virtual servers configurations.
Services []*service.Config `keepalive:"virtual_server"`
}
Config represents the configuration for virtual servers.
type ConfigFormat ¶
type ConfigFormat string
ConfigFormat represents the format in which the services configuration is loaded.
const ( // KeepalivedFormat represents the keepalived configuration format. KeepalivedFormat ConfigFormat = "keepalived" // JSONFormat represents the JSON configuration format. JSONFormat ConfigFormat = "json" // currently unused )
type ConfigLoader ¶
ConfigLoader is a function type for loading configuration.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the lifecycle of the services.
func New ¶
func New(announcer *announcer.Announcer, balancer *balancer.Balancer, metrics *metrics.ScopedMetrics, logger *log.Logger) *Core
New creates a new Core instance.
func (*Core) Reload ¶
Reload updates the Core with a new configuration.
It first updates the announcer with the new services' announce groups, ensuring the announcer is in sync with the latest configuration. Then, it either updates existing services or adds new ones based on the new configuration. Finally, it stops services that are no longer present in the new configuration and replaces the old services with the new ones.
func (*Core) Run ¶
Run starts the Core service.
It runs the core's worker pool. The core will continue running until its Stop method is invoked.
func (*Core) Status ¶
func (m *Core) Status() []*monalivepb.ServiceStatus
Status retrieves the current status of all services managed by the Core instance. It returns a slice of monalivepb.ServiceStatus messages representing the status of each service.
func (*Core) Stop ¶
func (m *Core) Stop()
Stop initiates a graceful shutdown of the Core and all its services. It ensures that no new services are started, and existing services are stopped. It uses the shutdown mechanism to signal that the Core should no longer accept new tasks and performs cleanup for all services.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a wrapper around the Core to facilitate external communication. It handles configuration loading, reloading, and status retrieval.
func NewManager ¶
func NewManager(config *ManagerConfig, core *Core, metrics metrics.Provider, logger *log.Logger) (*Manager, error)
NewManager creates a new Manager instance. It selects the appropriate configuration loader based on the format specified in the config.
func (*Manager) GetStatus ¶
func (m *Manager) GetStatus(ctx context.Context, _ *monalivepb.GetStatusRequest) (*monalivepb.GetStatusResponse, error)
GetStatus handles the RPC method to retrieve the current status of the service. It implements the GetStatus method defined in monalivepb. It returns a monalivepb.GetStatusResponse message containing the update timestamp and the current status of the services.
func (*Manager) Reload ¶
func (m *Manager) Reload(ctx context.Context, _ *monalivepb.ReloadRequest) (*monalivepb.ReloadResponse, error)
Reload handles the RPC method to reload the service configuration. Firstly, it loads the configuration using the selected loader. Then, it prepares the configuration by validating and processing it. Finally, it reloads the Core instance with the new configuration.
Implements the Reload method defined in monalivepb.
type ManagerConfig ¶
type ManagerConfig struct {
// Embedded ServicesConfig for configuration.
Services ServicesConfig `yaml:"services_config"`
}
ManagerConfig encapsulates the services configuration within a manager configuration.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics ...
func (*Metrics) DeleteService ¶
func (*Metrics) RealsEnabled ¶
func (*Metrics) RealsEnabledForService ¶
func (*Metrics) RealsErrorsForService ¶
func (m *Metrics) RealsErrorsForService(serviceLabels metrics.Labels) metrics.CounterVec
func (*Metrics) RealsForService ¶
func (*Metrics) RealsResponseTimeForService ¶
type ServicesConfig ¶
type ServicesConfig struct {
// Format of the services configuration file.
Format ConfigFormat `yaml:"format"`
// Path to the services configuration file.
Path string `yaml:"path"`
// Path where the dumped configuration will be saved.
DumpPath string `yaml:"dump_path"`
}
ServicesConfig defines the configuration for loading and dumping service configurations. It includes the format of the configuration file, the path to the configuration file, and the path where the dumped configuration will be saved.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package checker implements a health checking mechanism that handles the execution and processing of health checks, managing state transitions and event generation based on the results of these checks.
|
Package checker implements a health checking mechanism that handles the execution and processing of health checks, managing state transitions and event generation based on the results of these checks. |
|
check
Package check contains various implementations of the health check.
|
Package check contains various implementations of the health check. |
|
Package real implements the management of a real server entity.
|
Package real implements the management of a real server entity. |
|
Package service implements the management of virtual server entity.
|
Package service implements the management of virtual server entity. |