watcher

package
v0.0.0-...-afa4d9b Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TriggerManager

type TriggerManager interface {
	common.NotifySource
	Notify(*common.NotifyBatch)
}

A TriggerManager is both source and executor of triggers (notifications in common/notify.go terms).

func LoadTriggersFromDir

func LoadTriggersFromDir(dir string) (TriggerManager, error)

type Watcher

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

The Watcher is an asynchronous replication client that can operate on a subtree of the remote database. It will watch for changes and propagate them to the local database with low latency.

It also has the capability of executing path-specific triggers upon changes.

func New

func New(conn *grpc.ClientConn, store replds.Store, path string, triggers TriggerManager) *Watcher

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context)

Run the watcher. The replication algorithm is less terrible than the internal synchronization protocol:

  • establish a GRPC streaming connection to a server
  • send a summary of the local database state
  • receive all the missing Node objects
  • keep receiving further updates forever (as long as the streaming connection remains active).

This works because as long as we're connected to the same server, we know with certainty the state of both local and remote databases, and we can just push incremental updates from the server rather than running periodic (expensive) synchronizations. As a results, Watchers are comparatively lightweight, beyond the initial synchronization step.

Jump to

Keyboard shortcuts

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