-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All Resource Event Sources can handle multiple seconday resources for…
… a primary resources (#1169)
- Loading branch information
Showing
27 changed files
with
517 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...amework-core/src/main/java/io/javaoperatorsdk/operator/processing/MultiResourceOwner.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 13 additions & 9 deletions
22
...a/io/javaoperatorsdk/operator/processing/dependent/external/PollingDependentResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
package io.javaoperatorsdk.operator.processing.dependent.external; | ||
|
||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.EventSourceContext; | ||
import io.javaoperatorsdk.operator.processing.event.ExternalResourceCachingEventSource; | ||
import io.javaoperatorsdk.operator.processing.event.ResourceID; | ||
import io.javaoperatorsdk.operator.processing.event.source.CacheKeyMapper; | ||
import io.javaoperatorsdk.operator.processing.event.source.ExternalResourceCachingEventSource; | ||
import io.javaoperatorsdk.operator.processing.event.source.polling.PollingEventSource; | ||
|
||
public abstract class PollingDependentResource<R, P extends HasMetadata> | ||
extends AbstractPollingDependentResource<R, P> implements Supplier<Map<ResourceID, R>> { | ||
extends AbstractPollingDependentResource<R, P> | ||
implements PollingEventSource.GenericResourceFetcher<R> { | ||
|
||
private final CacheKeyMapper<R> cacheKeyMapper; | ||
|
||
public PollingDependentResource(Class<R> resourceType) { | ||
public PollingDependentResource(Class<R> resourceType, CacheKeyMapper<R> cacheKeyMapper) { | ||
super(resourceType); | ||
this.cacheKeyMapper = cacheKeyMapper; | ||
} | ||
|
||
public PollingDependentResource(Class<R> resourceType, long pollingPeriod) { | ||
public PollingDependentResource(Class<R> resourceType, long pollingPeriod, | ||
CacheKeyMapper<R> cacheKeyMapper) { | ||
super(resourceType, pollingPeriod); | ||
this.cacheKeyMapper = cacheKeyMapper; | ||
} | ||
|
||
@Override | ||
protected ExternalResourceCachingEventSource<R, P> createEventSource( | ||
EventSourceContext<P> context) { | ||
return new PollingEventSource<>(this, getPollingPeriod(), resourceType()); | ||
return new PollingEventSource<>(this, getPollingPeriod(), resourceType(), cacheKeyMapper); | ||
} | ||
|
||
} |
60 changes: 0 additions & 60 deletions
60
...java/io/javaoperatorsdk/operator/processing/event/ExternalResourceCachingEventSource.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ore/src/main/java/io/javaoperatorsdk/operator/processing/event/source/CacheKeyMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.javaoperatorsdk.operator.processing.event.source; | ||
|
||
public interface CacheKeyMapper<R> { | ||
|
||
String keyFor(R resource); | ||
|
||
/** | ||
* Used if a polling event source handles only single secondary resource. See also docs for: | ||
* {@link ExternalResourceCachingEventSource} | ||
* | ||
* @return static id mapper, all resources are mapped for same id. | ||
* @param <T> secondary resource type | ||
*/ | ||
static <T> CacheKeyMapper<T> singleResourceCacheKeyMapper() { | ||
return r -> "id"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.