Documentation
¶
Overview ¶
Package discovery provides interest-scoped service announcements over GossipSub. Providers announce routing keys (model IDs, tool names) on per-key topics only while those topics have subscribers; consumers subscribe only for keys they actively use. Cost therefore scales with interest, not mesh size. Announcements are routing hints authenticated by the pubsub layer's message signing — never authorization inputs.
Index ¶
Constants ¶
const ( // DefaultAnnounceInterval is how often a provider publishes on topics // with subscribers; each tick is jittered ±20%. DefaultAnnounceInterval = 10 * time.Second // DefaultInterestTTL is how long a consumer stays subscribed to a key's // topic after the last Ensure call for it. DefaultInterestTTL = 5 * time.Minute // DefaultStaleAfter is the age beyond which a provider entry is no // longer returned by Providers. DefaultStaleAfter = 30 * time.Second // DefaultMaxProviders bounds the consumer-side provider table. DefaultMaxProviders = 1024 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Announcement ¶
type Announcement struct {
Type api.ServiceType
Name string
Keys []string
Labels map[string]string
Load Load
}
Announcement is one service's advertised state, fed by the node.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery is the node-facing handle: it announces local services (provider role) and maintains an interest-scoped view of remote providers (consumer role) over a shared set of gossip topics.
func (*Discovery) Ensure ¶
func (d *Discovery) Ensure(t api.ServiceType, key string)
Ensure registers interest in a routing key: it subscribes to the key's topic (if not already) and refreshes the interest TTL. Safe to call on every request for the key.
func (*Discovery) PeerLabels ¶
PeerLabels returns the labels last observed for a peer, if any. Labels are node-level claims (e.g. region), so any fresh entry of the peer suffices.
type Option ¶
type Option func(*Discovery)
Option tweaks Discovery timing/bounds (used by tests).
func WithIntervals ¶
func WithMaxProviders ¶
type Provider ¶
type Provider struct {
PeerID string
Type api.ServiceType
Service string
Keys []string
Labels map[string]string
Load Load
LastSeen time.Time
}
Provider is a remote service observed via gossip.
type SourceFunc ¶
type SourceFunc func() []Announcement
SourceFunc supplies the current local announcements on each tick.