-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to using namespaced listers for eventtypes in data plane (#3951)
* feat: added factory for new eventtype listers Signed-off-by: Calum Murray <cmurray@redhat.com> * feat: used factory to get namespaced listers for eventtypes Signed-off-by: Calum Murray <cmurray@redhat.com> * feat: correctly pass lister factory to eventtytpe creator Signed-off-by: Calum Murray <cmurray@redhat.com> * fix: add license header Signed-off-by: Calum Murray <cmurray@redhat.com> * ./hack/update-codegen.sh Signed-off-by: Calum Murray <cmurray@redhat.com> --------- Signed-off-by: Calum Murray <cmurray@redhat.com>
- Loading branch information
Showing
6 changed files
with
63 additions
and
24 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
48 changes: 48 additions & 0 deletions
48
...rc/main/java/dev/knative/eventing/kafka/broker/core/eventtype/EventTypeListerFactory.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,48 @@ | ||
/* | ||
* Copyright © 2018 Knative Authors (knative-dev@googlegroups.com) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package dev.knative.eventing.kafka.broker.core.eventtype; | ||
|
||
import io.fabric8.kubernetes.client.informers.SharedIndexInformer; | ||
import io.fabric8.kubernetes.client.informers.cache.Lister; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class EventTypeListerFactory { | ||
private final Map<String, Lister<EventType>> listerMap; | ||
private final SharedIndexInformer<EventType> eventTypeInformer; | ||
|
||
public EventTypeListerFactory(SharedIndexInformer<EventType> eventTypeInformer) { | ||
if (eventTypeInformer == null) { | ||
throw new IllegalArgumentException("you must provide a non null eventtype informer"); | ||
} | ||
this.eventTypeInformer = eventTypeInformer; | ||
this.listerMap = new HashMap<>(); | ||
} | ||
|
||
public Lister<EventType> getForNamespace(String namespace) { | ||
if (this.listerMap.containsKey(namespace)) { | ||
return this.listerMap.get(namespace); | ||
} | ||
return this.createListerForNamespace(namespace); | ||
} | ||
|
||
private Lister<EventType> createListerForNamespace(String namespace) { | ||
final var lister = new Lister<>(this.eventTypeInformer.getIndexer(), namespace); | ||
this.listerMap.put(namespace, lister); | ||
return lister; | ||
} | ||
} |
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
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