Skip to content

Commit fd52590

Browse files
authored
chore(docs): fix javadoc and improve it (#774)
1 parent 37ea3a6 commit fd52590

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceInitializationContext.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package io.javaoperatorsdk.operator.api.reconciler;
22

33
import io.fabric8.kubernetes.api.model.HasMetadata;
4+
import io.javaoperatorsdk.operator.processing.event.source.EventSource;
45
import io.javaoperatorsdk.operator.processing.event.source.ResourceCache;
56

7+
/**
8+
* Contextual information made available to prepare event sources.
9+
*
10+
* @param <P> the type associated with the primary resource that is handled by your reconciler
11+
*/
612
public class EventSourceInitializationContext<P extends HasMetadata> {
713

814
private final ResourceCache<P> primaryCache;
@@ -11,6 +17,11 @@ public EventSourceInitializationContext(ResourceCache<P> primaryCache) {
1117
this.primaryCache = primaryCache;
1218
}
1319

20+
/**
21+
* Retrieves the cache that an {@link EventSource} can query to retrieve primary resources
22+
*
23+
* @return the primary resource cache
24+
*/
1425
public ResourceCache<P> getPrimaryCache() {
1526
return primaryCache;
1627
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public interface EventSourceInitializer<P extends HasMetadata> {
1616
/**
1717
* Prepares a list of {@link EventSource} implementations to be registered by the SDK.
1818
*
19-
* @param primaryCache a cache providing direct access to primary resources so that event sources
20-
* can extract relevant information from primary resources as needed
19+
* @param context a {@link EventSourceInitializationContext} providing access to information
20+
* useful to event sources
2121
*/
2222
List<EventSource> prepareEventSources(EventSourceInitializationContext<P> context);
2323

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/EventSource.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,30 @@
33
import io.javaoperatorsdk.operator.processing.LifecycleAware;
44
import io.javaoperatorsdk.operator.processing.event.EventHandler;
55

6+
/**
7+
* Creates an event source to trigger your reconciler whenever something happens to a secondary or
8+
* external resource that would not normally trigger your reconciler (as the primary resources are
9+
* not changed). To register EventSources with so that your reconciler is triggered, please make
10+
* your reconciler implement
11+
* {@link io.javaoperatorsdk.operator.api.reconciler.EventSourceInitializer}.
12+
*/
613
public interface EventSource extends LifecycleAware {
14+
15+
/**
16+
* An optional name for your EventSource. This is only required if you need to register multiple
17+
* EventSources for the same resource type (e.g. {@code Deployment}).
18+
*
19+
* @return the name associated with this EventSource
20+
*/
721
default String name() {
822
return getClass().getCanonicalName();
923
}
1024

25+
/**
26+
* Sets the {@link EventHandler} that is linked to your reconciler when this EventSource is
27+
* registered.
28+
*
29+
* @param handler the {@link EventHandler} associated with your reconciler
30+
*/
1131
void setEventHandler(EventHandler handler);
1232
}

0 commit comments

Comments
 (0)