Artifact 6ea2b767703aa297b4539e823fa29311937b6edd8dc374369a1576780770c370:
- File
cmd/edgesync/cli.go
— part of check-in
[f3d5aa96bc]
at
2026-05-11 15:26:31
on branch trunk
— feat(hub): machine-level hub CLI + ServerName / LeafUpstream config (#153)
Introduces `edgesync hub serve` and extends the hub package so a hub can be named at the NATS level and optionally solicit a leaf connection upstream. This is the substrate piece; session/agent vocabulary lives in a consumer (sesh) above this layer.
hub.Config: - ServerName — sets opts.ServerName on the embedded NATS server; surfaces in leafnode handshakes, varz, gossip. Empty leaves nats-server's auto-generated random name. - LeafUpstream — optional URL to solicit a leafnode connection toward. Wired to opts.LeafNode.Remotes. Lets one hub act as a leaf of another, enabling multi-hub topologies. - NATSStoreDir default renamed `nats-store` → `messaging` — implementation- agnostic on disk; contents underneath are still NATS JetStream format. The config field name stays `NATSStoreDir` (Go code is honest about what it is).
hub.Hub.ServerName() — getter returning the live identity (Config.ServerName or the auto-generated name).
cmd: `edgesync hub serve --name=<server-name> --leaf-upstream=<url> ...` defaults --name to <hostname>-hub and repo path to ~/.edgesync/<name>/hub.repo.
docs/architecture/hub-package.md updated to reflect the new fields, the messaging/ default, and a generic repo-file naming convention (the package itself doesn't impose a filename; the CLI defaults to hub.repo).
Verified end-to-end: - Hub solicits a hub: bidirectional pub/sub flows across two hubs on this machine via the leafnode handshake. - 3-edge star: 1 root hub + 3 leaf processes — fan-in, cross-leaf, subject filter all behave as expected. - ServerName visible at server-side truth (h.server.Name()). - 31 tests pass, vet clean.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> (user: [email protected], size: 613) [annotate] [blame] [check-ins using]
package main import ( edgecli "github.com/danmestas/EdgeSync/cli" repocli "github.com/danmestas/EdgeSync/cli/repo" ) type CLI struct { repocli.Globals Repo repocli.Cmd `cmd:"" help:"Repository operations"` Sync edgecli.SyncCmd `cmd:"" help:"Leaf agent sync"` Bridge edgecli.BridgeCmd `cmd:"" help:"NATS-to-Fossil bridge"` Hub edgecli.HubCmd `cmd:"" help:"Embedded NATS + fossil hub (root or soliciting via --leaf-upstream)"` Notify edgecli.NotifyCmd `cmd:"" help:"Bidirectional notification messaging"` Doctor edgecli.DoctorCmd `cmd:"" help:"Check development environment health"` }