Skip to content

@grest-ts/discovery-local

IPC-based service discovery for local development and testing. Used internally by the framework — you typically don't interact with this package directly.

For a full overview of how discovery works, see the Discovery guide.

What it does

Runs a local discovery server that acts as a central router. Service instances connect over IPC, register their routes, and discover each other through the router. The router also acts as a reverse proxy, forwarding requests to the correct backend based on path prefix matching.

Exported classes

ClassPurpose
GGLocalDiscoveryClientConnects to an existing discovery server
GGLocalDiscoveryResilientClientAdds leader election with automatic failover — multiple instances compete for the router port, and if the leader dies, a follower takes over
GGLocalDiscoveryServerThe router itself

Testkit

Available via @grest-ts/discovery-local/testkit:

  • GGLocalRoutingStrategySelector — controls routing strategies in tests (e.g. first, roundRobin, or a custom strategy)