instance.resolve/v1
How a control plane (a mothership) decides what a hostname serves for a given edge, from its own records. The watch server (instance.watch/v1) asks it on every watch and asks again after every write to a record an answer depends on, so a resolver only has to be right; it never tracks changes.
A service contract on the mothership app (resolve.go).
Use
resolvev1.Contract.Must(app) after registration:
Resolve(ctx, Query{Edge, Host}): the instance (nil: no such host) and itsDeps.Standing(ctx, edge): instances the edge must hold whatever its traffic, with their deps.Edges(ctx): every edge, with the list's deps.Touches(ctx, record): the deps a write of the record touches besides its own record and collection.
Deps are strings built with resolvev1.Record(collection, id), Collection(name) (any record of it),
Host(name) (whoever claims the name) and Key(name) (the resolver's own, such as which record is edge lax-1).
Provide
Implement resolvev1.Resolver and provide it on the mothership app. ext/mothership's
Schema provides the default over its edges and instances collections; a control plane with its own collections
provides its own, and one that only adds to the default's answers wraps it (Contract.Wrap).
Touches should report only what a write changed (compare rec.Original()): a record written often, such as an edge's
heartbeat, mustn't re-resolve every answer that merely looked it up.
Extensions
| Extension | |
|---|---|
| mothership | provides (default) |
| mothership | requires |
License
MIT
Questions and comments
Comments are a GitHub Discussions thread; sign in with GitHub to post.