Documentation
¶
Overview ¶
Package engineask keeps a host's overlay engine carrying the topics an application needs: it asks the engine on the same host for them (POST /admin/topics, an engine route that answers loopback callers only) and asks again before the ask lapses.
An ask has an id, a lifetime and the list items it appends to the engine's settings. The engine carries the items while the ask lives, reloads only the modules they change, and its overlay bridge then asks the delivery edge for the topics. Asking again with the same id replaces the ask, so an application that restarts with other buckets replaces what it asked for before, at once.
An Asker does not withdraw its ask when it stops. A restart, the common case, asks again within the lifetime, so the topics never stop and the edge never withdraws and grants them again; an application that stays stopped has its ask lapse after the lifetime. Nothing is kept on disk.
Index ¶
Constants ¶
const DefaultTTL = 10 * time.Minute
DefaultTTL is an ask's lifetime when none is set. Engines bound it (OVERLAY_TOPICS_DYNAMIC_MAX_TTL_SECONDS; a week by default, ten minutes on the lab hosts), so it is kept short.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Asker ¶
type Asker struct {
// URL is the engine's base URL, such as http://127.0.0.1:8280.
URL string
// ID names the ask; asking again with it replaces the ask.
ID string
// TTL is the ask's lifetime; it is asked again at half of it. Zero is
// DefaultTTL.
TTL time.Duration
// Settings are the list items asked for, by setting: OVERLAY_TOPICS
// and the lists of the module that carries them.
Settings map[string][]string
// Client defaults to a client with a 10 s timeout.
Client *http.Client
// Logf reports a change of outcome: the first success, and each
// refusal or failure that differs from the last. Nil logs nothing.
Logf func(format string, args ...any)
// OnResult, when set, is told the outcome of every ask.
OnResult func(ok bool)
// contains filtered or unexported fields
}
Asker keeps one ask alive. Set the fields, then call Run.
func (*Asker) Run ¶
Run asks at once and again at half the lifetime, until ctx is done. A failed ask is tried again sooner, from 1 s doubling to the refresh interval, so an engine that was restarting is asked as soon as it answers. A refused ask is tried again at the refresh interval, and reported each time: nothing it asks for is carried until it is fixed.
type Refused ¶
Refused is an engine's refusal of the ask: 400 (the engine does not allow a setting, an item, the lifetime, or one more ask), 403 (the caller is not on the engine's host), 404 or 405 (an engine without the route), 413. Asking again changes nothing until the engine's or the application's settings do. Every other answer, 408, 425 and 429 included, is a failure that passes.