Skip to content

Question & Opinion) ResourceController's init(EventSourceManager) method feels a bit vague. #615

Closed
@heesuk-ahn

Description

@heesuk-ahn

HI, all
I was wondering how to register eventSource in Controller, so I looked at the code.

https://github.com/java-operator-sdk/java-operator-sdk/blob/2e8f219437e53b9ca58f146a24397dbf38f0bfb8/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java#L55

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 :)

Metadata

Metadata

Assignees

Labels

api-changes-epicneeds-discussionIssue needs to be discussed more before working on ittriage/supportIndicates an issue that is a support question.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions