Description
HI, all
I was wondering how to register eventSource in Controller, so I looked at the code.
Looking at this method, it looks like I can create and use my own EventSourceManager
.
However, in reality, when operator.start()
starts, DefaultEventSourceManager
is unconditionally injected in configuredController.
(https://github.com/java-operator-sdk/java-operator-sdk/blob/2e8f219437e53b9ca58f146a24397dbf38f0bfb8/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/ConfiguredController.java#L178-L179)
And actually, the user should directly register the EventSource
that the user wants to register with the EventSourceManager inside the init method.
like this
@Override
public void init(EventSourceManager eventSourceManager) {
...
eventSourceManager.registerEventSource(eventSource);
}
Personally, I think this might be a bit ambiguous.
It feels like the user can directly inject and use CustomEventSourceManager .
If that's not what you intended, Rather, I think the interface below would be a little clearer.
public interface ResourceController<R extends CustomResource> {
...
default List<EventSource> registerEventSources() {
return List.of();
}
}
And by calling this method in the framework, it will be able to directly register it with the event source manager.
Since EventSourceManager
is an important component in the framework, it seems to be able to prevent it from being directly exposed to users.
This is just my personal opinion.
Thank you for reading this question :)