engineask

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 10 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 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

View Source
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) Ask

func (a *Asker) Ask(ctx context.Context) error

Ask sends the ask once.

func (*Asker) Check

func (a *Asker) Check() error

Check reports whether the asker is usable.

func (*Asker) Run

func (a *Asker) Run(ctx context.Context)

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

type Refused struct {
	Status int
	Reason string
}

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.

func (*Refused) Error

func (e *Refused) Error() string

Jump to

Keyboard shortcuts

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