From 1c702e71d3be1a95124f54f9fdff934e9f87ad3a Mon Sep 17 00:00:00 2001 From: Thomas Crowley Date: Thu, 19 Dec 2024 10:51:49 +1100 Subject: [PATCH] Deprecate io.operatr.kpow.StreamsRegistry --- README.md | 5 +++-- .../io/factorhouse/kpow/key/ManualKeyStrategy.java | 14 -------------- src/java/io/operatr/kpow/StreamsRegistry.java | 11 +++++++++-- 3 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 src/java/io/factorhouse/kpow/key/ManualKeyStrategy.java diff --git a/README.md b/README.md index 4259603..e19995e 100644 --- a/README.md +++ b/README.md @@ -191,11 +191,12 @@ If you have set a UI-friendly cluster name using the `ENVIRONMENT_NAME` environm ```java -import io.factorhouse.kpow.key.ManualKeyStrategy; // This sets a manual key of `Trade Book (Staging)`, the name of the clusters environment name in Kpow's UI. KeyStrategy keyStrategy = new ManualKeyStrategy("Trade Book (Staging)"); -registry.register(streams, topology, keyStrategy); +registry. + + register(streams, topology, keyStrategy); ``` ### Minimum Required ACLs diff --git a/src/java/io/factorhouse/kpow/key/ManualKeyStrategy.java b/src/java/io/factorhouse/kpow/key/ManualKeyStrategy.java deleted file mode 100644 index 872cd06..0000000 --- a/src/java/io/factorhouse/kpow/key/ManualKeyStrategy.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.factorhouse.kpow.key; - -public class ManualKeyStrategy implements KeyStrategy { - private final String envName; - - public ManualKeyStrategy(String envName) { - this.envName = envName; - } - - @Override - public Taxon getTaxon(String clientId, String applicationId) { - return new Taxon("env", envName, "streams-agent", clientId); - } -} diff --git a/src/java/io/operatr/kpow/StreamsRegistry.java b/src/java/io/operatr/kpow/StreamsRegistry.java index 8366e56..087b675 100644 --- a/src/java/io/operatr/kpow/StreamsRegistry.java +++ b/src/java/io/operatr/kpow/StreamsRegistry.java @@ -3,6 +3,7 @@ import clojure.java.api.Clojure; import clojure.lang.IFn; import io.factorhouse.kpow.MetricFilter; +import io.factorhouse.kpow.key.KeyStrategy; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.common.serialization.Serializer; import org.apache.kafka.streams.KafkaStreams; @@ -11,6 +12,12 @@ import java.util.ArrayList; import java.util.Properties; + +/** + * @deprecated This class is no longer recommended for use. + * Please use {@link io.factorhouse.kpow.StreamsRegistry} instead. + */ +@Deprecated public class StreamsRegistry implements AutoCloseable { public static class StreamsAgent { @@ -91,11 +98,11 @@ public StreamsRegistry(Properties props) { this(props, MetricFilter.defaultMetricFilter()); } - public StreamsAgent register(KafkaStreams streams, Topology topology) { + public StreamsAgent register(KafkaStreams streams, Topology topology, KeyStrategy keyStrategy) { IFn require = Clojure.var("clojure.core", "require"); require.invoke(Clojure.read("io.factorhouse.kpow.agent")); IFn registerFn = Clojure.var("io.factorhouse.kpow.agent", "register"); - String id = (String) registerFn.invoke(agent, streams, topology); + String id = (String) registerFn.invoke(agent, streams, topology, keyStrategy); if (id != null) { return new StreamsAgent(id); } else {