state

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package state manages traefik dynamic configurations per environment, merging local files and agent submissions into a single master config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent added in v0.4.0

type Agent struct {
	Name      string    `json:"name"`
	Addr      string    `json:"addr"`
	Connected bool      `json:"connected"`
	Since     time.Time `json:"since"`
	Updated   time.Time `json:"updated"`
	Routers   int       `json:"routers"`
	Services  int       `json:"services"`
	// contains filtered or unexported fields
}

Agent is a tetherd instance pushing its container config.

type Collision added in v0.4.0

type Collision struct {
	Kind   string `json:"kind"`
	Name   string `json:"name"`
	Source string `json:"source"`
	Owner  string `json:"owner"`
}

Collision is an entry skipped because an earlier source already defined it differently.

type Config added in v0.4.0

type Config map[string]any

Config is a traefik dynamic configuration as plain JSON values. Tether only reads the layout (sections, entry maps, router services, load balancer servers), everything else passes through untouched, so it works with any traefik version.

type SharedService added in v0.4.0

type SharedService struct {
	Name    string   `json:"name"`
	Agents  []string `json:"agents"`
	Servers []string `json:"servers"`
}

SharedService is an HTTP service load balanced across several agents.

type Snapshot added in v0.4.0

type Snapshot struct {
	Config     Config          `json:"config"`
	Agents     []Agent         `json:"agents"`
	Collisions []Collision     `json:"collisions"`
	Shared     []SharedService `json:"shared"`
}

Snapshot is the merged view of one environment. Never mutated after creation.

type State

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

State holds traefik configurations grouped by environment.

func New

func New(ctx context.Context, localFile string) (*State, error)

New creates the state and, if localFile is set, loads and watches it until ctx is done.

func (*State) AgentConnected added in v0.4.0

func (s *State) AgentConnected(env, name, addr string)

AgentConnected registers a new connection for the agent.

func (*State) AgentDisconnected added in v0.4.0

func (s *State) AgentDisconnected(env, name string)

AgentDisconnected drops a connection. Once the agent has no connections left its routes are kept for expireAfter, then removed unless it reconnects.

func (*State) EnvNames added in v0.4.0

func (s *State) EnvNames() []string

EnvNames returns all registered environment names, sorted.

func (*State) Snapshot added in v0.4.0

func (s *State) Snapshot(env string) *Snapshot

Snapshot returns the current merged view of the environment.

func (*State) Subscribe

func (s *State) Subscribe(env string) chan *Snapshot

Subscribe returns a channel that receives snapshots for the environment.

func (*State) Unsubscribe

func (s *State) Unsubscribe(env string, ch chan *Snapshot)

Unsubscribe removes a subscription channel.

func (*State) UpdateAgent

func (s *State) UpdateAgent(env, name string, cfg Config)

UpdateAgent replaces an agent's config and rebuilds the environment.

func (*State) WatchUpstream added in v0.7.0

func (s *State) WatchUpstream(ctx context.Context, name, url string)

WatchUpstream polls another traefik http provider endpoint until ctx is done. It shows up as an agent called name, so it merges and expires like one.

Jump to

Keyboard shortcuts

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