-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for writing tags along with events to Sink (#2850)
* Updated to pass SinkContext to Sink constructors as suggested in the previous comments Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com> * Fixed check style errors and renamed RoutedPluginSetting to SinkContextPluginSetting Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com> * Fixed s3-sink integration test Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com> * Added javadoc for SinkContext Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com> Co-authored-by: Krishna Kondaka <krishkdk@dev-dsk-krishkdk-2c-bd29c437.us-west-2.amazon.com>
Showing
33 changed files
with
451 additions
and
131 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
39 changes: 39 additions & 0 deletions
39
data-prepper-api/src/main/java/org/opensearch/dataprepper/model/sink/SinkContext.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,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.model.sink; | ||
|
||
import java.util.Collection; | ||
|
||
/** | ||
* Data Prepper Sink Context class. This the class for keeping global | ||
* sink configuration as context so that individual sinks may use them. | ||
*/ | ||
public class SinkContext { | ||
private final String tagsTargetKey; | ||
private final Collection<String> routes; | ||
|
||
public SinkContext(final String tagsTargetKey, final Collection<String> routes) { | ||
this.tagsTargetKey = tagsTargetKey; | ||
this.routes = routes; | ||
} | ||
|
||
/** | ||
* returns the target key name for tags if configured for a given sink | ||
* @return tags target key | ||
*/ | ||
public String getTagsTargetKey() { | ||
return tagsTargetKey; | ||
} | ||
|
||
/** | ||
* returns routes if configured for a given sink | ||
* @return routes | ||
*/ | ||
public Collection<String> getRoutes() { | ||
return routes; | ||
} | ||
} | ||
|
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
33 changes: 33 additions & 0 deletions
33
data-prepper-api/src/test/java/org/opensearch/dataprepper/model/sink/SinkContextTest.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,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.model.sink; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
|
||
|
||
|
||
public class SinkContextTest { | ||
private SinkContext sinkContext; | ||
|
||
@Test | ||
public void testSinkContextBasic() { | ||
final String testTagsTargetKey = RandomStringUtils.randomAlphabetic(6); | ||
final List<String> testRoutes = Collections.emptyList(); | ||
sinkContext = new SinkContext(testTagsTargetKey, testRoutes); | ||
assertThat(sinkContext.getTagsTargetKey(), equalTo(testTagsTargetKey)); | ||
assertThat(sinkContext.getRoutes(), equalTo(testRoutes)); | ||
|
||
} | ||
|
||
} | ||
|
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 |
---|---|---|
|
@@ -3,5 +3,6 @@ customSinkPlugin: | |
routes: | ||
- "routeA" | ||
- "routeB" | ||
tags_target_key: "tags" | ||
key1: "value1" | ||
key2: "value2" |
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
Oops, something went wrong.