vchag commented on code in PR #2962:
URL: https://github.com/apache/polaris/pull/2962#discussion_r2492777138
##########
runtime/service/src/main/java/org/apache/polaris/service/events/listeners/aws/cloudwatch/AwsCloudWatchEventListener.java:
##########
@@ -71,13 +78,38 @@ public class AwsCloudWatchEventListener extends
PropertyMapEventListener {
public AwsCloudWatchEventListener(
AwsCloudWatchConfiguration config,
Clock clock,
- PolarisIcebergObjectMapperCustomizer customizer) {
+ PolarisIcebergObjectMapperCustomizer customizer,
+ ObjectMapper mapper) {
this.logStream = config.awsCloudWatchLogStream();
this.logGroup = config.awsCloudWatchLogGroup();
this.region = Region.of(config.awsCloudWatchRegion());
this.synchronousMode = config.synchronousMode();
this.clock = clock;
+ this.objectMapper = mapper;
customizer.customize(this.objectMapper);
+ this.listenToAllEvents =
+ config.eventTypes().isEmpty()
+ || config.eventTypes().map(Set::isEmpty).orElse(true)
+ || config.eventTypes().get().stream().anyMatch(e -> e ==
PolarisEvent.class);
+ this.allowedEventTypes = listenToAllEvents ? Set.of() :
Set.copyOf(config.eventTypes().get());
+ }
+
+ @Override
+ protected boolean shouldHandle(Object event) {
+ if (!(event instanceof PolarisEvent polarisEvent)) {
+ return false;
+ }
+
+ if (this.listenToAllEvents) {
+ return true;
+ }
+ Class<? extends PolarisEvent> actualType = polarisEvent.getClass();
Review Comment:
@adutra
Fair point.
1. In addition to using numeric event type IDs, I’m thinking of including a
human-readable code string in each PolarisEventType. Any thoughts?
e.g.
```
public enum PolarisEventType {
AFTER_REFRESH_TABLE(101, "after_refresh_table"),
BEFORE_REFRESH_TABLE(102, "before_refresh_table"),
UNKNOWN(0, "unknown"),
ALL(-1, "all");
```
2. For polaris.event-listener.aws-cloudwatch.event-types property, should we
accept IDs, codes, or keep supporting class names only?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]