configsync

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 8 Imported by: ? 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 configsync lets the OFREP bulk evaluation answer a client that was notified of a newer configuration than the one the relay has loaded: the relay checks its control plane first, within a bound, and answers with what it then has. It never fails a request and never waits without a bound.

Index

Constants

View Source
const (
	// Wait is the longest a request waits for the control plane check that its flagConfigEtag or
	// flagConfigLastModified asks for. The request context ends the wait earlier.
	Wait = 2 * time.Second
	// MinInterval is the shortest time between two control plane checks that requests start: a client that names a
	// configuration that never comes (a made-up value) costs the control plane one check per interval, for the
	// whole relay, however many requests it sends. A request that arrives while a check runs waits for that check.
	MinInterval = time.Second

	// QueryETag is the query parameter of the OFREP bulk evaluation that carries the etag of the change notification.
	QueryETag = "flagConfigEtag"
	// QueryLastModified is the query parameter that carries the lastModified of the change notification.
	QueryLastModified = "flagConfigLastModified"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Gate

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

Gate starts the control plane checks that requests ask for. A request that is behind is answered only after a check that started after it arrived (or when its wait ends), so it never takes the state it found as the answer to a notification. The checks are at least MinInterval apart: a request that finds no slot free waits for the next one, and the requests that arrive before that check starts share it.

func NewGate

func NewGate() *Gate

NewGate returns a gate on the clock of the process and on real timers.

func NewGateWith

func NewGateWith(now func() time.Time, after func(time.Duration) <-chan time.Time) *Gate

NewGateWith returns a gate that reads the time from now and waits for a slot with after (a timer that fires once after the duration): tests give it a clock and timers they drive.

func (*Gate) CheckNow

func (g *Gate) CheckNow(ctx context.Context, refresher service.Refresher) bool

CheckNow asks the control plane for the latest configuration for a request that is behind, and waits for the answer: for the slot of its check (at most one check starts per MinInterval) and for the check itself, in all at most Wait and never longer than ctx. It reports whether a check that started after the request arrived finished; false means the wait ended first, and the caller answers with what the relay has.

type Target

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

Target is the configuration a request names. The zero value names none.

func FromRequest

func FromRequest(r *http.Request) (Target, bool)

FromRequest reads the parameters of the request. It allocates nothing when the request carries neither of them (the common case): the raw query is searched before it is parsed. A value that cannot be read is as if it was not sent, a request is never refused for it.

func (Target) Behind

func (t Target) Behind(set service.ConfigVersioned) bool

Behind reports whether the flag set serves another configuration than the one named. The ETag decides when it is sent; otherwise the configuration is behind when it was built before the named date (whole seconds).

Jump to

Keyboard shortcuts

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