-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca8cb95
commit dd4dc7b
Showing
10 changed files
with
138 additions
and
34 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
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
10 changes: 10 additions & 0 deletions
10
src/java/io/factorhouse/kpow/key_strategies/ClientIDKeyStrategy.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,10 @@ | ||
package io.factorhouse.kpow.key_strategies; | ||
|
||
public class ClientIDKeyStrategy implements KeyStrategy { | ||
public ClientIDKeyStrategy() {} | ||
|
||
@Override | ||
public Taxon getTaxon(String clientId, String applicationId) { | ||
return new Taxon("streams", clientId, "streams-agent", null); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/java/io/factorhouse/kpow/key_strategies/ClusterIDKeyStrategy.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,22 @@ | ||
package io.factorhouse.kpow.key_strategies; | ||
|
||
import org.apache.kafka.clients.admin.AdminClient; | ||
import org.apache.kafka.clients.admin.DescribeClusterResult; | ||
import java.util.Properties; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class ClusterIDKeyStrategy implements KeyStrategy { | ||
private final String clusterID; | ||
|
||
public ClusterIDKeyStrategy(Properties props) throws InterruptedException, ExecutionException { | ||
try (AdminClient adminClient = AdminClient.create(props)) { | ||
DescribeClusterResult describeClusterResult = adminClient.describeCluster(); | ||
this.clusterID = describeClusterResult.clusterId().get(); | ||
} | ||
} | ||
|
||
@Override | ||
public Taxon getTaxon(String clientId, String applicationId) { | ||
return new Taxon("streams", clusterID, "streams-agent-cid", clientId); | ||
} | ||
} |
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,5 @@ | ||
package io.factorhouse.kpow.key_strategies; | ||
|
||
public interface KeyStrategy { | ||
Taxon getTaxon(String clientId, String applicationId); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/java/io/factorhouse/kpow/key_strategies/ManualKeyStrategy.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,14 @@ | ||
package io.factorhouse.kpow.key_strategies; | ||
|
||
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("streams", envName, "streams-agent-m", clientId); | ||
} | ||
} |
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,32 @@ | ||
package io.factorhouse.kpow.key_strategies; | ||
|
||
public class Taxon { | ||
private final String domain; | ||
private final String id; | ||
|
||
private final String object; | ||
private final String objectId; | ||
|
||
public Taxon(String domain, String id, String object, String objectId) { | ||
this.id = id; | ||
this.domain = domain; | ||
this.object = object; | ||
this.objectId = objectId; | ||
} | ||
|
||
public String getDomain() { | ||
return domain; | ||
} | ||
|
||
public String getObject() { | ||
return object; | ||
} | ||
|
||
public String getObjectId() { | ||
return objectId; | ||
} | ||
|
||
public String getId() { | ||
return 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