-
Improvement
-
Resolution: Done
-
Medium
-
None
There are a number of lifecycle problems in this API.
ServiceRegistration is not idempotent. It would be nice if it were an AutoCloseable instance – yangtools.concepts.Registration preferrably, but we cannot quite have that now. Anyway unregister() should have a much-preferred idempotent close().
Furthermore ServiceDescriptor takes moduleServiceName which is also supplied to DiagStatusService.register(). This means that ServiceRegistration knows this name and hence could provide a newDescriptor(ServiceState) method without users passing this in.
Finally DiagStatusService.report() takes a ServiceDescriptor and a ServiceState, both of which are required.
Let us have a:
interface DiagStatus implements AutoCloseable { void report(ServiceState state); @Override close(); }
which replaces ServiceRegistration.