When a new service instance comes up, it needs to register, pass a health check, get added
to routing, and notify downstream consumers -- all before traffic arrives. This workflow
registers the service with real DNS resolution via InetAddress.getAllByName, health-checks
the endpoint, updates routing rules (writing to a local file), and notifies consumers with
their resolved addresses.
serviceName, endpoint, version, healthCheckUrl
|
v
+----------------+ +-------------------+ +----------------------+ +------------------------+
| sd_register | --> | sd_health_check | --> | sd_update_routing | --> | sd_notify_consumers |
+----------------+ +-------------------+ +----------------------+ +------------------------+
registrationId DNS resolution of routing file written consumer DNS resolved
+ DNS resolved health endpoint active instances counted notification sent
addresses
RegisterWorker -- Registers serviceName at endpoint with version. Performs real
DNS resolution via InetAddress.getAllByName on the endpoint hostname. Returns
registrationId, resolvedAddresses, and dnsResolved flag.
HealthCheckWorker -- Resolves the health check endpoint's DNS and validates the service.
Returns the endpoint, serviceName, version, and resolvedAddress.
UpdateRoutingWorker -- Updates routing for the service: resolves the endpoint address,
checks port reachability, counts active instances, and writes a routing file to disk.
Returns updated: true.
NotifyConsumersWorker -- Notifies downstream consumers about the service availability update. Resolves each consumer's DNS and marks them as notified.
30 unit tests cover registration, health checks, routing updates, and consumer notification.
See ../../RUNNING.md for setup and execution instructions.