Documentation
¶
Index ¶
- Variables
- type Config
- type EtcdLeaseManager
- func (l *EtcdLeaseManager) AfterLease(ctx context.Context) chan struct{}
- func (l *EtcdLeaseManager) LeaseID() (clientv3.LeaseID, error)
- func (l *EtcdLeaseManager) RevokeCurrentLease(ctx context.Context) error
- func (l *EtcdLeaseManager) Shutdown(ctx context.Context)
- func (l *EtcdLeaseManager) Start(ctx context.Context)
- type EtcdMutex
- type FailoverConfig
- type FailoverManager
- type KeyChangeNotifier
- type MetricsAggregator
- type Monitorable
- type NodeosMonitor
- type ProcessFailureHandler
- type ProcessMonitor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoLease is returned when a lease isn't active for a // EtcdLeaseManager. ErrNoLease = errors.New("error: lease not active") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
LogFormat string
DebugMode bool
NodeosPath string
NodeosArgs []string
ActiveConfigDir string
StandbyConfigDir string
EtcdEndpoints []string
EtcdCertPath string
EtcdKeyPath string
EtcdCAPath string
FailoverGroup string
MetricsHTTPAddr string
}
Config are all of the different options available for use by a monitor.
type EtcdLeaseManager ¶
type EtcdLeaseManager struct {
// contains filtered or unexported fields
}
EtcdLeaseManager always maintains an Etcd lease, notifying through a channel when the current lease is lost.
func NewEtcdLeaseManager ¶
func NewEtcdLeaseManager(clock clock.Clock, leaseClient clientv3.Lease) *EtcdLeaseManager
NewEtcdLeaseManager instantiates a new EtcdLeaseManager.
func (*EtcdLeaseManager) AfterLease ¶
func (l *EtcdLeaseManager) AfterLease(ctx context.Context) chan struct{}
AfterLease returns a channel that's closed when a lease has been attained.
func (*EtcdLeaseManager) LeaseID ¶
func (l *EtcdLeaseManager) LeaseID() (clientv3.LeaseID, error)
LeaseID returns the current Etcd lease ID.
func (*EtcdLeaseManager) RevokeCurrentLease ¶
func (l *EtcdLeaseManager) RevokeCurrentLease(ctx context.Context) error
RevokeCurrentLease revokes the current lease. This makes it so that the LeaseManager requests a new lease.
func (*EtcdLeaseManager) Shutdown ¶
func (l *EtcdLeaseManager) Shutdown(ctx context.Context)
Shutdown shuts down the lease manager, revoking all leases.
func (*EtcdLeaseManager) Start ¶
func (l *EtcdLeaseManager) Start(ctx context.Context)
Start begins the process of attaining and renewing leases.
type EtcdMutex ¶
type EtcdMutex struct {
// contains filtered or unexported fields
}
EtcdMutex provides a mutex on Etcd that locks based on a key.
func NewEtcdMutex ¶
func NewEtcdMutex(id, key string, kvClient clientv3.KV, leaseManager *EtcdLeaseManager) *EtcdMutex
NewEtcdMutex creates a new EtcdMutex.
type FailoverConfig ¶
type FailoverConfig struct {
ID string
EtcdKey string
Clock clock.Clock
LeaseManager *EtcdLeaseManager
WatcherClient clientv3.Watcher
KVClient clientv3.KV
ActiveProcess Monitorable
StandbyProcess Monitorable
}
FailoverConfig contains the parameters for a FailoverManager.
type FailoverManager ¶
type FailoverManager struct {
// contains filtered or unexported fields
}
FailoverManager manages a failover system for a process using Etcd. The active version of a Monitorable is activated when a lock is attained on an Etcd key. The standby version of a process is activated when the lock is lost or if it isn't attainable. Additionally, FailoverManager supports being notified of a downstream failure, which causes it to lose its Etcd lease and restart.
func NewFailoverManager ¶
func NewFailoverManager(config *FailoverConfig) *FailoverManager
NewFailoverManager instantiates a new FailoverManager.
func (*FailoverManager) HandleFailure ¶
func (f *FailoverManager) HandleFailure(ctx context.Context, m Monitorable)
HandleFailure is called by an external process in order to restart the FailoverManager, losing any currently active leases.
func (*FailoverManager) Shutdown ¶
func (f *FailoverManager) Shutdown(ctx context.Context)
Shutdown shuts down the failover manager, killing the underlying active process.
func (*FailoverManager) Start ¶
func (f *FailoverManager) Start(ctx context.Context)
Start begins the FailoverManager process. The process runs asynchronously until the context is canceled.
func (*FailoverManager) TryActivate ¶
func (f *FailoverManager) TryActivate(ctx context.Context) error
TryActivate forces an activation, waiting for a least to be attained.
type KeyChangeNotifier ¶
type KeyChangeNotifier struct {
// contains filtered or unexported fields
}
KeyChangeNotifier notifies a channel when an Etcd key is modified.
func NewKeyChangeNotifier ¶
func NewKeyChangeNotifier(key string, watcherClient clientv3.Watcher, changeChan chan *mvccpb.KeyValue) *KeyChangeNotifier
NewKeyChangeNotifier instantiates a new KeyChangeNotifier.
func (*KeyChangeNotifier) Start ¶
func (k *KeyChangeNotifier) Start(ctx context.Context)
Start begins the key change notification process.
type MetricsAggregator ¶
type MetricsAggregator struct {
HealthCheckLatencies *prometheus.HistogramVec
ActiveProcesses prometheus.Gauge
StandbyProcesses prometheus.Gauge
LeadershipTransitions *prometheus.CounterVec
ProcessFailures prometheus.Counter
LeasesAttained prometheus.Counter
LeasesLost prometheus.Counter
KeyChangesDetected prometheus.Counter
ActivationAttempts prometheus.Counter
StandbyAttempts prometheus.Counter
BlocksProduced prometheus.Counter
BlocksReceived prometheus.Counter
}
MetricsAggregator contains the different Prometheus metrics that the application tracks.
func NewMetricsAggregator ¶
func NewMetricsAggregator() *MetricsAggregator
NewMetricsAggregator creates a new MetricsAggregator.
type Monitorable ¶
type Monitorable interface {
Activate(context.Context, ProcessFailureHandler) error
Shutdown(context.Context) error
}
Monitorable is a type that can be activated and shutdown. In this codebase, a Monitorable is usually an actual OS process.
type NodeosMonitor ¶
type NodeosMonitor struct {
// contains filtered or unexported fields
}
NodeosMonitor contains the services needed to run an EOS Nodeos Process monitor.
func NewNodeosMonitor ¶
func NewNodeosMonitor(conf *Config) (*NodeosMonitor, error)
NewNodeosMonitor creates a new NodeosMonitor instance.
func (*NodeosMonitor) Shutdown ¶
func (n *NodeosMonitor) Shutdown(ctx context.Context)
Shutdown shuts down the failover manager.
func (*NodeosMonitor) Start ¶
func (n *NodeosMonitor) Start(ctx context.Context)
Start begins the Nodeos monitoring process. Start runs asynchronously and immediately returns.
type ProcessFailureHandler ¶
type ProcessFailureHandler interface {
HandleFailure(ctx context.Context, m Monitorable)
}
ProcessFailureHandler is something that's called when a process fails.
type ProcessMonitor ¶
type ProcessMonitor struct {
// contains filtered or unexported fields
}
ProcessMonitor monitors a process informing a handler when the process fails.
func NewProcessMonitor ¶
func NewProcessMonitor(path string, args []string) *ProcessMonitor
NewProcessMonitor returns a new instance of ProcessMonitor.
func (*ProcessMonitor) Activate ¶
func (p *ProcessMonitor) Activate(ctx context.Context, failureHandler ProcessFailureHandler) error
Activate starts the underlying process.
func (*ProcessMonitor) IsActive ¶
func (p *ProcessMonitor) IsActive() bool
IsActive returns true if the underlying process is active.