Documentation
¶
Overview ¶
Package coordclient keeps an engine's registration and peer set current against a coordination service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run registers e with the coordination service, applies the first netmap to it, and returns. It then keeps running until ctx ends: it registers again whenever the engine's registration changes and every refresh_seconds that the latest netmap announces, and it long-polls the netmap, applying each one to the engine. A netmap's hosts become the engine's peers with a lease that ends lease_seconds after the request started, and its regions, or the default region, become the engine's signaling regions.
Run fails, without starting workers, when BaseURL is not an acceptable HTTPS URL, when the engine is closed, or when the first registration or netmap fails. A 401 or 403 answer to any request expires the engine's peers at once. After a failed background netmap request the client waits before it asks again: one second, doubling with each consecutive failure up to thirty seconds, and never less than the service's Retry-After (capped at one minute). After a 429 answer it keeps the netmap version, so the next request can hold instead of returning at once. A failed registration is tried again on the next change or refresh.
Types ¶
type Options ¶
type Options struct {
BaseURL string
TLSConfig *tls.Config
Headers func(context.Context) (http.Header, error)
Logger *slog.Logger
}
Options configures Run.
BaseURL is the HTTPS base of the coordination service. The client appends "/registration" and "/netmap" to it; a trailing slash is ignored. It must not carry user information, a query or a fragment. When a netmap lists no regions, the client gives the engine one region named BaseURL + "/signal" with ID 0.
TLSConfig verifies the service; nil selects the platform defaults.
Headers supplies every header of every request, and the client sends no other header of its own: it sends no User-Agent and asks for no compression, and the only header it adds is the Content-Length of the registration body. It is called once per request. Its error fails the request and stays wrapped, so an ErrNoCredential result can be matched with errors.Is. A nil Headers sends none.
Logger receives warnings about failed requests; nil discards them.