Documentation
¶
Overview ¶
Package fleet implements pure, deterministic worker-node selection, per-site telemetry folding, monotonic job timestamps, and multi-shard rotation shared between the self-hosted Go Hub (internal/hub) and the Cloudflare Worker Durable Object coordinator (via cmd/edgefetch-wasm).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRoutablePublicIP ¶
IsRoutablePublicIP reports whether rawIP is a valid non-loopback, non-private, non-link-local IP address suitable for WAN egress grouping.
func NextJobStamp ¶
NextJobStamp returns a strictly increasing job timestamp >= now, >= last+1, and >= floor.
func OrderCandidates ¶
OrderCandidates splits cands into idle vs busy (using case-insensitive site IDs), groups each partition by publicIp (falling back to siteId), orders groups by Least-Recently-Used (then earliest connectedAt, then group key), orders members within each group by LRU (then earliest connectedAt, then siteId), and interleaves members across distinct IP groups.
func ShardOrder ¶
ShardOrder deterministically rotates shards using FNV-1a(lower(trim(hint))). When hint is empty or len(shards) <= 1, a copy of shards in original order is returned.
Types ¶
type Candidate ¶
type Candidate struct {
SiteID string `json:"siteId"`
PublicIP string `json:"publicIp,omitempty"`
LastJobAt int64 `json:"lastJobAt"`
ConnectedAt int64 `json:"connectedAt"`
}
Candidate describes one connected remote worker node eligible for dispatch.
type PlanRequest ¶
type PlanRequest struct {
Candidates []Candidate `json:"candidates,omitempty"`
Busy []string `json:"busy,omitempty"`
Stats map[string][]Stats `json:"stats,omitempty"`
StatsList []Stats `json:"statsList,omitempty"`
Now int64 `json:"now,omitempty"`
LastStamp int64 `json:"lastStamp,omitempty"`
Floor int64 `json:"floor,omitempty"`
ShardHint string `json:"shardHint,omitempty"`
ShardSeq uint64 `json:"shardSeq,omitempty"`
Shards []string `json:"shards,omitempty"`
}
PlanRequest bundles all inputs for the single `fleet_plan` WASM op.
type PlanResponse ¶
type PlanResponse struct {
Order []string `json:"order,omitempty"`
MergedStats map[string]Stats `json:"mergedStats,omitempty"`
FoldedStats *Stats `json:"foldedStats,omitempty"`
NextStamp int64 `json:"nextStamp,omitempty"`
ShardOrder []string `json:"shardOrder,omitempty"`
}
PlanResponse returns the full fleet decision in one call.
func Plan ¶
func Plan(req PlanRequest) PlanResponse
Plan evaluates candidate dispatch order, per-site stats folding, monotonic stamp advancement, and shard rotation in one call.
type Stats ¶
type Stats struct {
SiteID string `json:"siteId,omitempty"`
LastJobAt int64 `json:"lastJobAt"`
JobsOK int64 `json:"jobsOk"`
JobsErr int64 `json:"jobsErr"`
}
Stats holds cumulative per-site job counters and the last-job timestamp (epoch ms).
func MergeStats ¶
MergeStats returns the component-wise maximum of two Stats records (clamped >= 0).