-
Notifications
You must be signed in to change notification settings - Fork 218
improve: PerResourcePollingEventSource init improvements #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.OperatorException; | ||
import io.javaoperatorsdk.operator.api.reconciler.EventSourceContext; | ||
import io.javaoperatorsdk.operator.processing.event.ResourceID; | ||
import io.javaoperatorsdk.operator.processing.event.source.Cache; | ||
import io.javaoperatorsdk.operator.processing.event.source.CacheKeyMapper; | ||
|
@@ -43,19 +44,49 @@ public class PerResourcePollingEventSource<R, P extends HasMetadata> | |
private final long period; | ||
private final Set<ResourceID> fetchedForPrimaries = ConcurrentHashMap.newKeySet(); | ||
|
||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
EventSourceContext<P> context, Duration defaultPollingPeriod, | ||
Class<R> resourceClass) { | ||
this(resourceFetcher, context.getPrimaryCache(), defaultPollingPeriod.toMillis(), | ||
null, resourceClass, | ||
CacheKeyMapper.singleResourceCacheKeyMapper()); | ||
} | ||
|
||
@Deprecated(forRemoval = true) | ||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
Cache<P> resourceCache, long period, Class<R> resourceClass) { | ||
this(resourceFetcher, resourceCache, period, null, resourceClass, | ||
CacheKeyMapper.singleResourceCacheKeyMapper()); | ||
} | ||
|
||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
EventSourceContext<P> context, | ||
Duration defaultPollingPeriod, | ||
Class<R> resourceClass, | ||
CacheKeyMapper<R> cacheKeyMapper) { | ||
this(resourceFetcher, context.getPrimaryCache(), defaultPollingPeriod.toMillis(), | ||
null, resourceClass, cacheKeyMapper); | ||
} | ||
|
||
@Deprecated(forRemoval = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
Cache<P> resourceCache, long period, Class<R> resourceClass, | ||
CacheKeyMapper<R> cacheKeyMapper) { | ||
this(resourceFetcher, resourceCache, period, null, resourceClass, cacheKeyMapper); | ||
} | ||
|
||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
EventSourceContext<P> context, | ||
Duration defaultPollingPeriod, | ||
Predicate<P> registerPredicate, | ||
Class<R> resourceClass, | ||
CacheKeyMapper<R> cacheKeyMapper) { | ||
this(resourceFetcher, context.getPrimaryCache(), defaultPollingPeriod.toMillis(), | ||
registerPredicate, resourceClass, cacheKeyMapper, | ||
new ScheduledThreadPoolExecutor(DEFAULT_EXECUTOR_THREAD_NUMBER)); | ||
} | ||
|
||
@Deprecated(forRemoval = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
Cache<P> resourceCache, long period, | ||
Predicate<P> registerPredicate, Class<R> resourceClass, | ||
|
@@ -64,7 +95,20 @@ public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | |
new ScheduledThreadPoolExecutor(DEFAULT_EXECUTOR_THREAD_NUMBER)); | ||
} | ||
|
||
public PerResourcePollingEventSource(ResourceFetcher<R, P> resourceFetcher, | ||
|
||
public PerResourcePollingEventSource( | ||
ResourceFetcher<R, P> resourceFetcher, | ||
EventSourceContext<P> context, Duration defaultPollingPeriod, | ||
Predicate<P> registerPredicate, Class<R> resourceClass, | ||
CacheKeyMapper<R> cacheKeyMapper, ScheduledExecutorService executorService) { | ||
this(resourceFetcher, context.getPrimaryCache(), defaultPollingPeriod.toMillis(), | ||
registerPredicate, | ||
resourceClass, cacheKeyMapper, executorService); | ||
} | ||
|
||
@Deprecated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
public PerResourcePollingEventSource( | ||
ResourceFetcher<R, P> resourceFetcher, | ||
Cache<P> resourceCache, long period, | ||
Predicate<P> registerPredicate, Class<R> resourceClass, | ||
CacheKeyMapper<R> cacheKeyMapper, ScheduledExecutorService executorService) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify in the javadoc using the @deprecated attribute what is supposed to be used instead.