Services

A service is an interface or class instance registered in a node's service registry. Other plugins can look it up and use it without depending on the private implementation.
The service registry
The service registry is one of the central components of a nyssr.net node. It publishes capabilities through interfaces while keeping implementation details private.
This is the framework's code-hiding principle:
- Clients depend on an interface
- The implementation can change independently
- Services can be supplied by plugins loaded at runtime
- A service can be replaced without changing every consumer
Services start when dependencies are ready
A service is not started unconditionally. A class implementing IServiceStarter tells the system that it can be started and declares its dependencies.
When all required services are available, the starter's start method creates and registers the service. If a dependency disappears, the stop method removes it again. This keeps the running system consistent as plugins are added or removed.
Key idea: The service registry turns runtime availability into an explicit contract instead of hiding dependencies in global initialization code.
Why not classic dependency injection?
nyssr.net is asynchronous, and plugins are loaded dynamically. A dependency may become available later or disappear while the node is running. The service-registry pattern handles that lifecycle directly.
It requires some additional code in the service starter, but the behavior remains visible and predictable.
Typical lifecycle
- Declare the required service interfaces
- Wait until the dependencies are available
- Create and register the service
- Use the service through its interface
- Stop and deregister it when a dependency is removed