syncer

package
v0.0.0-...-e562d1a Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ProxyContainerName = "falcon-proxy"

Variables

This section is empty.

Functions

This section is empty.

Types

type Syncer

type Syncer struct {
	Client       *client.Client
	Context      context.Context
	CancelFunc   context.CancelFunc
	EventChannel <-chan events.Message
	ContainerId  string
}

Syncer is the class responsible for ensuring that the Traefik container stays in sync with all Docker networks on the machine, joining them when they're created and leaving them when they're destroyed. Note that an empty Syncer will NOT work. You must call the `NewSyncer` function instead.

func NewSyncer

func NewSyncer() (Syncer, error)

Creates a new ProxySyncer struct for syncing a container with all Docker networks on a machine. Returns an empty struct and an error if it was unable to construct the Docker client.

func (Syncer) Sync

func (syncer Syncer) Sync() error

Sync determines what networks the proxy container needs to join and which networks it needs to leave and joins and leaves those networks as appropriate. It does this by determining which networks the syncer container is already a part of and which networks are considered valid. If the syncer hasn't joined a valid network, it joins it. If the syncer is still part of an invalid network, then it leaves it.

While this is more expensive to compute than say, listening to all network connect/leave events and determining the action based on the network event, it is much more durable. If something goes wrong and one sync errors for some strange reason or if we miss an event, we can "catch up" on the next network event, rather than be stuck in an invalid state until the container is restarted.

Jump to

Keyboard shortcuts

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