A factory that constructs a registry entry from the service registry.
This is the "factory arm" of a registration option: an entry that is a
function is called — once, at the onInit phase — with the application's
IServiceRegistry, and its return value is the instance the
option would have accepted. It exists so a generated artifact (a command
handler, event handler, or health indicator) can reach a capability — the
event bus, the logger, the database — that its contract's single message
parameter cannot carry.
The argument is named services at every call site. It is deliberately the
registry and nothing narrower: everything a generated artifact could want is
reachable through it under a CAPABILITIES token, and a narrower context
would ship with no in-repo reader.
Do not confuse with ServiceFactory: that is a no-argument lazy
factory the registry invokes on first lookup, whereas this takes the
registry as its one argument and is invoked by a plugin's onInit hook.
A factory that constructs a registry entry from the service registry.
This is the "factory arm" of a registration option: an entry that is a function is called — once, at the
onInitphase — with the application'sIServiceRegistry, and its return value is the instance the option would have accepted. It exists so a generated artifact (a command handler, event handler, or health indicator) can reach a capability — the event bus, the logger, the database — that its contract's single message parameter cannot carry.The argument is named
servicesat every call site. It is deliberately the registry and nothing narrower: everything a generated artifact could want is reachable through it under aCAPABILITIEStoken, and a narrower context would ship with no in-repo reader.Do not confuse with
ServiceFactory: that is a no-argument lazy factory the registry invokes on first lookup, whereas this takes the registry as its one argument and is invoked by a plugin'sonInithook.