ae

package
v1.13.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2023 License: MPL-2.0 Imports: 7 Imported by: 37

Documentation

Overview

Package ae provides tools to synchronize state between local and remote consul servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StateSyncer

type StateSyncer struct {
	// State contains the data that needs to be synchronized.
	State SyncState

	// Interval is the time between two full sync runs.
	Interval time.Duration

	// ShutdownCh is closed when the application is shutting down.
	ShutdownCh chan struct{}

	// Logger is the logger.
	Logger hclog.Logger

	// ClusterSize returns the number of members in the cluster to
	// allow staggering the sync runs based on cluster size.
	// This needs to be set before Run() is called.
	ClusterSize func() int

	// SyncFull allows triggering an immediate but staggered full sync
	// in a non-blocking way.
	SyncFull *Trigger

	// SyncChanges allows triggering an immediate partial sync
	// in a non-blocking way.
	SyncChanges *Trigger
	// contains filtered or unexported fields
}

StateSyncer manages background synchronization of the given state.

The state is synchronized on a regular basis or on demand when either the state has changed or a new Consul server has joined the cluster.

The regular state synchronization provides a self-healing mechanism for the cluster which is also called anti-entropy.

func NewStateSyncer

func NewStateSyncer(state SyncState, intv time.Duration, shutdownCh chan struct{}, logger hclog.Logger) *StateSyncer

func (*StateSyncer) Pause

func (s *StateSyncer) Pause()

Pause temporarily disables sync runs.

func (*StateSyncer) Paused

func (s *StateSyncer) Paused() bool

Paused returns whether sync runs are temporarily disabled.

func (*StateSyncer) Resume

func (s *StateSyncer) Resume() bool

Resume re-enables sync runs. It returns true if it was the last pause/resume pair on the stack and so actually caused the state syncer to resume.

func (*StateSyncer) Run

func (s *StateSyncer) Run()

Run is the long running method to perform state synchronization between local and remote servers.

type SyncState

type SyncState interface {
	SyncChanges() error
	SyncFull() error
}

type Trigger

type Trigger struct {
	// contains filtered or unexported fields
}

Trigger implements a non-blocking event notifier. Events can be triggered without blocking and notifications happen only when the previous event was consumed.

func NewTrigger

func NewTrigger() *Trigger

func (Trigger) Notif

func (t Trigger) Notif() <-chan struct{}

func (Trigger) Trigger

func (t Trigger) Trigger()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL