public class EventStreamConfig extends Object
Modifier and Type | Class and Description |
---|---|
static class |
EventStreamConfig.Builder
Builder, builder pattern to construct
EventStreamConfig instances.
|
Modifier and Type | Field and Description |
---|---|
static String |
EVENT_SERVICE_SETTING
Stream Config setting name for destination event service name.
|
protected com.google.common.collect.ImmutableMap<String,URI> |
eventServiceToUriMap
Maps event service name to a service URL.
|
protected EventStreamConfigLoader |
eventStreamConfigLoader
Used to load stream config at instantiation and on demand.
|
static String |
MESSAGE_KEY_FIELDS_SETTING
Stream config setting name for Kafka message partition keys.
|
static String |
SCHEMA_TITLE_SETTING
Stream Config setting name for schema title.
|
protected com.fasterxml.jackson.databind.node.ObjectNode |
streamConfigsCache
Cached stream configurations.
|
static String |
TOPICS_SETTING
Stream config topics setting.
|
Modifier | Constructor and Description |
---|---|
protected |
EventStreamConfig(EventStreamConfigLoader eventStreamConfigLoader,
Map<String,URI> eventServiceToUriMap)
EventStreamConfig constructor.
|
Modifier and Type | Method and Description |
---|---|
static EventStreamConfig.Builder |
builder()
Returns an Builder instance.
|
com.fasterxml.jackson.databind.node.ObjectNode |
cachedStreamConfigs()
Returns all cached stream configs.
|
List<String> |
cachedStreamNames()
Returns all cached stream name keys.
|
List<com.fasterxml.jackson.databind.JsonNode> |
collectAllCachedSettings(String settingName)
Collects all settingName values of every cached stream config entry.
|
List<String> |
collectAllCachedSettingsAsString(String settingName)
Collects all settingName values of every cached stream config entry as a String
If the value is an array, its contents will be flattened.
|
List<com.fasterxml.jackson.databind.JsonNode> |
collectSetting(String streamName,
String settingName)
Collects the settingName value for streamName.
|
List<String> |
collectSettingAsString(String streamName,
String settingName)
Collects the settingName value as a String for streamName.
|
List<com.fasterxml.jackson.databind.JsonNode> |
collectSettingMatchingSettings(String settingName,
List<String> streamNames,
Map<String,String> settingsFilters)
Collect all settingName values for the list of specified streams
with settings that match the provided settingsFilters.
|
List<String> |
collectSettingMatchingSettingsAsString(String settingName,
List<String> streamNames,
Map<String,String> settingsFilters)
Collect all settingName values as Strings for the list of specified streams
with settings that match the provided settingsFilters.
|
List<com.fasterxml.jackson.databind.JsonNode> |
collectSettings(List<String> streamNames,
String settingName)
Collects all settingName values for each of the listed streamNames.
|
List<String> |
collectSettingsAsString(List<String> streamNames,
String settingName)
Collects all settingName values as a String for each of the listed streamNames.
|
List<String> |
collectTopics(List<String> streamNames)
Get all topics settings for the list of specified streams.
|
List<String> |
collectTopicsMatchingSettings(List<String> streamNames,
Map<String,String> settingsFilters)
Get all topics settings for the list of specified streams
with settings that match the provided settingsFiilters.
|
Stream<com.fasterxml.jackson.databind.JsonNode> |
elementsStream()
Returns a Java Stream iterator over the stream config entries.
|
Stream<Map.Entry<String,com.fasterxml.jackson.databind.JsonNode>> |
fieldsStream()
Returns a Java Stream iterator over the Map.Entry of stream name to stream config entries.
|
com.fasterxml.jackson.databind.node.ObjectNode |
filterStreamConfigs(List<String> streamNames,
Map<String,String> settingsFilters)
Filter stream configs for streamNames that match the settingsFilters.
|
List<String> |
getAllCachedTopics()
Get all topics settings for all known streams.
|
String |
getEventServiceName(String streamName)
Gets the destination_event_service name for the specified stream.
|
URI |
getEventServiceUri(String streamName)
Gets the default event service URI for this stream via the EVENT_SERVICE_SETTING.
|
URI |
getEventServiceUri(String streamName,
String datacenter)
Gets a datacenter specific destination event service URI for this stream
via the EVENT_SERVICE_SETTING + the datacenter name.
|
URI |
getEventServiceUriByServiceName(String eventServiceName)
Gets the event service POST URI of an event service.
|
com.fasterxml.jackson.databind.JsonNode |
getMessageKeyFields(String streamName)
Get the Kafka message key fields for a given stream.
|
String |
getSchemaTitle(String streamName)
Get all topics settings for the a single stream.
|
com.fasterxml.jackson.databind.JsonNode |
getSetting(String streamName,
String settingName)
Gets a stream config setting for a specific stream.
|
String |
getSettingAsString(String streamName,
String settingName)
Gets the stream config setting for a specific stream as a string.
|
com.fasterxml.jackson.databind.node.ObjectNode |
getStreamConfig(String streamName)
Returns the stream config entry for a specific stream.
|
com.fasterxml.jackson.databind.node.ObjectNode |
getStreamConfigs(List<String> streamNames)
Gets the stream config entries for the desired stream names.
|
List<String> |
getTopics(String streamName)
Get all topics settings for a single stream.
|
protected static List<String> |
jsonNodesAsText(Collection<com.fasterxml.jackson.databind.JsonNode> jsonNodes)
Converts a List of JsonNodes to a List of Strings using JsonNode::asText.
|
protected static List<com.fasterxml.jackson.databind.JsonNode> |
objectNodeCollectValues(com.fasterxml.jackson.databind.node.ObjectNode objectNode,
String fieldName)
Finds all values of fieldName of each element in objectNode.
|
void |
reset()
Re-fetches the content for all stream configs and saves it in the local
stream configs cache.
|
boolean |
streamExists(String streamName)
Returns true if the stream is declared in stream config.
|
static String |
toRegex(Collection<String> strings)
Converts a list of strings to a regex that will match
any of the strings.
|
String |
toString() |
public static final String TOPICS_SETTING
public static final String SCHEMA_TITLE_SETTING
public static final String EVENT_SERVICE_SETTING
public static final String MESSAGE_KEY_FIELDS_SETTING
protected com.google.common.collect.ImmutableMap<String,URI> eventServiceToUriMap
protected EventStreamConfigLoader eventStreamConfigLoader
protected com.fasterxml.jackson.databind.node.ObjectNode streamConfigsCache
protected EventStreamConfig(EventStreamConfigLoader eventStreamConfigLoader, Map<String,URI> eventServiceToUriMap)
public static EventStreamConfig.Builder builder()
public final void reset()
public Stream<com.fasterxml.jackson.databind.JsonNode> elementsStream()
public Stream<Map.Entry<String,com.fasterxml.jackson.databind.JsonNode>> fieldsStream()
public com.fasterxml.jackson.databind.node.ObjectNode filterStreamConfigs(List<String> streamNames, Map<String,String> settingsFilters)
public com.fasterxml.jackson.databind.node.ObjectNode cachedStreamConfigs()
public boolean streamExists(String streamName)
public com.fasterxml.jackson.databind.node.ObjectNode getStreamConfig(String streamName)
getStreamConfigs(my_stream)
returns
{ my_stream: { schema_title: my/schema, ... } }
public com.fasterxml.jackson.databind.node.ObjectNode getStreamConfigs(List<String> streamNames)
public com.fasterxml.jackson.databind.JsonNode getSetting(String streamName, String settingName)
JsonNode setting = getSetting("mediawiki.revision-create", "destination_event_service")
returns
TextNode("eventgate-main")
You'll still have to pull the value out of the JsonNode wrapper yourself.
E.g. setting.asText() or setting.asDouble()
If either this streamName does not have a stream config entry, or
the stream config entry does not have setting, this returns null.streamName
- name of stream in stream configsettingName
- setting name to get, either top level field name, or JsonPointer
starting with '/'.public String getSettingAsString(String streamName, String settingName)
JsonNode setting = getSettingAsString("mediawiki.revision-create", "destination_event_service")
returns "eventgate-main"
If either this streamName does not have a stream config entry, or
the stream config entry does not have setting, this returns null.public List<com.fasterxml.jackson.databind.JsonNode> collectSetting(String streamName, String settingName)
{ stream1: { setting1: [val1, val2] }, stream2: { setting1: [val3, val4] } returns [val1, val2, val3, val4] collectSetting("stream2", "setting1") returns [JsonNode("val3"), JsonNode("val4")]
public List<String> collectSettingAsString(String streamName, String settingName)
{ stream1: { setting1: [val1, val2] }, stream2: { setting1: [val3, val4] } returns [val1, val2, val3, val4] collectSettingAsString("stream2", "setting1") returns ["val3", "val4"]
public List<com.fasterxml.jackson.databind.JsonNode> collectSettings(List<String> streamNames, String settingName)
{ stream1: { setting1: [val1, val2] }, stream2: { setting1: [val3, val4] } returns [val1, val2, val3, val4] collectSettings(["stream1", "stream2"], "setting1") returns [JsonNode("val1"), JsonNode("val2"), JsonNode("val3"), JsonNode("val4")]
public List<String> collectSettingsAsString(List<String> streamNames, String settingName)
{ stream1: { setting1: [val1, val2] }, stream2: { setting1: [val3, val4] } returns [val1, val2, val3, val4] collectSettingsAsString(["stream1", "stream2"], "setting1") returns ["val1", "val2", "val3", "val4"]
public List<com.fasterxml.jackson.databind.JsonNode> collectAllCachedSettings(String settingName)
{ stream1: { setting1: [val1, val2] }, stream2: { setting1: [val3, val4] } returns [val1, val2, val3, val4] collectAllCachedSettings("setting1") returns [JsonNode("val1"), JsonNode("val2"), JsonNode("val3"), JsonNode("val4")]
public List<String> collectAllCachedSettingsAsString(String settingName)
{ stream1: { setting1: [val1, val2] }, stream2: { setting1: [val3, val4] } returns [val1, val2, val3, val4] collectAllCachedSettingsAsString(setting1") returns ["val1", "val2", "val3", "val4"]
public List<com.fasterxml.jackson.databind.JsonNode> collectSettingMatchingSettings(String settingName, List<String> streamNames, Map<String,String> settingsFilters)
public List<String> collectSettingMatchingSettingsAsString(String settingName, List<String> streamNames, Map<String,String> settingsFilters)
public com.fasterxml.jackson.databind.JsonNode getMessageKeyFields(String streamName)
streamName
- the target streampublic String getSchemaTitle(String streamName)
public List<String> getAllCachedTopics()
public List<String> getTopics(String streamName)
public List<String> collectTopics(List<String> streamNames)
public List<String> collectTopicsMatchingSettings(List<String> streamNames, Map<String,String> settingsFilters)
public String getEventServiceName(String streamName)
public static String toRegex(Collection<String> strings)
("a", "/^b.+/", "c") returns "(a|^b.+|c)"Use this for converting a list of topics to a regex like:
EventStreamConfig.toRegex(
eventStreamConfig.getAllCachedTopics()
);
public URI getEventServiceUriByServiceName(String eventServiceName)
public URI getEventServiceUri(String streamName)
public URI getEventServiceUri(String streamName, String datacenter)
protected static List<com.fasterxml.jackson.databind.JsonNode> objectNodeCollectValues(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String fieldName)
{ key1: { targetField: val1 }, key2: { targetField: val2 } } returns [val1, val2] { key1: { targetField: [val1, val2] }, key2: { targetField: [val3, val4] } returns [val1, val2, val3, val4]
protected static List<String> jsonNodesAsText(Collection<com.fasterxml.jackson.databind.JsonNode> jsonNodes)
Copyright © 2025. All rights reserved.