From 5e11bc13a7b1fb4b943f451adcb0f09da9a14e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Mon, 28 Aug 2023 14:24:52 +0200 Subject: [PATCH 1/3] feat: Convenience filterAll consumer filter --- .../akka/projection/grpc/consumer/ConsumerFilter.scala | 6 ++++++ docs/src/main/paradox/grpc.md | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala b/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala index a00e83418..d23e159d8 100644 --- a/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala +++ b/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala @@ -90,6 +90,12 @@ object ConsumerFilter extends ExtensionId[ConsumerFilter] { sealed trait FilterCriteria sealed trait RemoveCriteria extends FilterCriteria + /** + * Exclude events from all entity ids, convenience for combining with for example a topic filter + * to include only events matching the topic filter. + */ + val filterAll = ExcludeRegexEntityIds(Set(".*")) + /** * Exclude events with any of the given tags, * unless there is a matching include filter that overrides the exclude. diff --git a/docs/src/main/paradox/grpc.md b/docs/src/main/paradox/grpc.md index 33cb0ed75..7d6c77589 100644 --- a/docs/src/main/paradox/grpc.md +++ b/docs/src/main/paradox/grpc.md @@ -173,6 +173,10 @@ events are still transferred to the consumer, to ensure sequence number validati Filters can be used when a consumer is only interested in a subset of the entities. The filters can be defined on both the producer side and on the consumer side, and they can be changed at runtime. +By default, all events are emitted, and filters selectively choose what events to filter out. For some of the filters +it is useful to first define a @apidoc[ConsumerFilter.filterAll](ConsumerFilter) filter and then selectively include events. +For example to only include events from topics matching topic filters. + @@@ note The purpose of filters is to toggle if all events for the entity are to be emitted or not. From 59b9fcb8ffda58c28f8ca9909f29d7cb85b2c537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Mon, 28 Aug 2023 19:06:20 +0200 Subject: [PATCH 2/3] filterAll => excludeAll for clarity --- .../scala/akka/projection/grpc/consumer/ConsumerFilter.scala | 2 +- docs/src/main/paradox/grpc.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala b/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala index d23e159d8..bd45f666e 100644 --- a/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala +++ b/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala @@ -94,7 +94,7 @@ object ConsumerFilter extends ExtensionId[ConsumerFilter] { * Exclude events from all entity ids, convenience for combining with for example a topic filter * to include only events matching the topic filter. */ - val filterAll = ExcludeRegexEntityIds(Set(".*")) + val excludeAll = ExcludeRegexEntityIds(Set(".*")) /** * Exclude events with any of the given tags, diff --git a/docs/src/main/paradox/grpc.md b/docs/src/main/paradox/grpc.md index 7d6c77589..63fd21db2 100644 --- a/docs/src/main/paradox/grpc.md +++ b/docs/src/main/paradox/grpc.md @@ -174,7 +174,7 @@ Filters can be used when a consumer is only interested in a subset of the entiti on both the producer side and on the consumer side, and they can be changed at runtime. By default, all events are emitted, and filters selectively choose what events to filter out. For some of the filters -it is useful to first define a @apidoc[ConsumerFilter.filterAll](ConsumerFilter) filter and then selectively include events. +it is useful to first define a @apidoc[ConsumerFilter.excludeAll](ConsumerFilter$) filter and then selectively include events. For example to only include events from topics matching topic filters. @@@ note From 2a3f9a5eeb9f60a0a325f8c548bb1ff1e1ce23db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Andr=C3=A9n?= Date: Tue, 29 Aug 2023 11:36:22 +0200 Subject: [PATCH 3/3] explicit but less specific type --- .../scala/akka/projection/grpc/consumer/ConsumerFilter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala b/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala index bd45f666e..63a9e9698 100644 --- a/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala +++ b/akka-projection-grpc/src/main/scala/akka/projection/grpc/consumer/ConsumerFilter.scala @@ -94,7 +94,7 @@ object ConsumerFilter extends ExtensionId[ConsumerFilter] { * Exclude events from all entity ids, convenience for combining with for example a topic filter * to include only events matching the topic filter. */ - val excludeAll = ExcludeRegexEntityIds(Set(".*")) + val excludeAll: FilterCriteria = ExcludeRegexEntityIds(Set(".*")) /** * Exclude events with any of the given tags,