ServiceSpec.Context documented which addresses a service must end up with, but nothing read it, so a typo'd context was accepted and meant nothing. Review caught it as scaffolding that looked load-bearing. RegisterService now validates it: an unknown context, or a hosted (server/both) service registered with no default listen address, panics. Registrations come from this repository's own init(), never from operator input, so an invalid one is a programming error with no caller positioned to handle an error return, and failing at process start beats a service binding where nobody dials. Services.RequireTarget replaces the same check and message hand-written in composeStateStoreClient and composeChatContract. An empty registered default target is what declares a target operator-supplied, so the requirement belongs to the registry rather than to each consumer. It stays a lazy check at composition time rather than becoming load-time validation: a process that never dials a service must still load a configuration that omits it. The review's stated failure mode does not occur. A hosted service with an empty listen does not reach net.Listen as an ephemeral port; resolveServiceListen returns "no listen address" and archied refuses to start. The defect was the inert field, not a silent bind. Refs: archie-core-u23g
21 lines
865 B
Go
21 lines
865 B
Go
package archied
|
|
|
|
import (
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
|
|
"github.com/samcharles93/archie-core/internal/secret"
|
|
)
|
|
|
|
// composeStateStoreClient dials the State Store gRPC service the daemon's own
|
|
// capture/mapping/binding consumers call. Token resolution is the daemon's
|
|
// (it owns the config keys and the secret registry); the dial itself and the
|
|
// fail-closed non-loopback rule (§9) belong to the transport, so they come
|
|
// from staterpc.Dial.
|
|
func composeStateStoreClient(services config.Services, secrets *secret.Registry) (*staterpc.Client, func(), error) {
|
|
target, err := services.RequireTarget(config.ServiceNameState)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
return staterpc.Dial(target, services.ResolvedToken(config.ServiceNameState, secrets.Getenv))
|
|
}
|