Add support for multiple filters in consumer grous#40
Conversation
… configurations Refactored filtering logic, added utility methods, extended validations, updated related tests, and enhanced handling of wildcard-based partitioning.
…astic consumer groups.
…features in consumer groups
|
Hey @colprog, does this make sense to you? thanks |
|
Hi @mtmk , Thanks for coming up with a patch so quickly. This is exactly what I wanted. If I understand correctly, using [-1] as partitioningWildcards will require nats-server 2.12+? |
|
hey @colprog
spot on! yes, server must be 2.12+ hence the test failures on 2.10 and 2.11. fixing them now. edit: tests are fixed. |
…el features in consumer group configurations
|
@jnmoyne @piotrpio heads up, this PR adds two .NET-only extensions to PCGroups that aren't in
Would be good to get your thoughts on whether these make sense to standardize across implementations, or if you'd approach them differently in Go. |
|
This is great, thanks! Actually there have been a few changes to the Go implementation lately and it's due for a new release, and we should synchronize the two. Multi-filter has actually already be done in Go :) synadia-io/orbit.go#44. The one difference however is since the plan is to cut a new release (as soon at that last PR gets merged in) I decided to add I like the idea of -1 for partition on the whole subject, so I'll add that to Go (and Java). Note that there are other PRs that have merged to the Go version since the original release with some small improvements that you should check out. |
|
Using -1 for partition, we could support orders.> or even > as filter, Is this something we should pursue is a future release? |
|
I would rather have |
…th `NatsPcgPartitioningFilter`, simplify validations, and update related tests.
|
thanks @jnmoyne I think all the feedback is addressed:
JSON config in KV should now be interoperable with Go and Java. |
|
hey @colprog thanks for getting the ball rolling on this one. Please let us know how you get on with the changes and please fell free to review the code if you have some time. |
|
Thanks, The changes looks good. |
jnmoyne
left a comment
There was a problem hiding this comment.
LGTM (after the changes since my last review)
|
Actually, as I implemented partitioning on the whole subject in Go I made another correlated improvement that you should also implement in .net to keep interoperability: for elastic simply you can have the "partitioning_filters" array be empty (while currently it will error out if you don't specify at least one partitioning filter), and in that case (the length of the array is 0) the library should simply have a single filter for ">" (and destination "{{Partition(x)}}.>") for the consumer it creates. |
|
Hi @mtmk, any news on this? |
|
apologies @colprog I have been busy with the client codebase last couple of week. I'll try to give this a priority next week. |
|
Thanks monty, looking forward to the new release. |
Use unique GUID-based subject prefixes in all elastic tests to prevent "subjects overlap with an existing stream" errors when multiple TFMs share the same NATS server in CI. Add SkipBelow212Async to the empty PartitioningFilters test since full-subject partitioning requires NATS 2.12+. Fix the work-queue stream name assertion (was incorrectly prefixed with "pcg-") and add proper cleanup in try/finally.
Use GoHarness to verify cross-language interop with orbit.go pcgroups v0.2.0. Three tests cover .NET-creates/Go-consumes, Go-creates/.NET-consumes, and empty PartitioningFilters interop.
ElasticConsume uses priority groups which require NATS 2.11+. The Go process exits with an error on 2.10, causing the test to fail on ReadLineAsync.
Filters(string array) only — removed singleFilterpropertyPartitioningFiltersarray of{filter, partitioning_wildcards}pairs, removed separateFilter/Filters/PartitioningWildcardspropertiespartitioning_wildcardsarray[]instead of[-1]sentinel{partition}.{filter}(e.g.,0.orders.*) instead of{partition}.>partitioning_filtersarray defaults to>with full-subject partitioning (matches orbit.go PR Add helper to delete elastic work queue consumers #46)orbit.go/[email protected]Cross-implementation compatibility
JSON config stored in NATS KV is interoperable with Go (
pcgroups/v0.2.0) and Java:"filters"string array (no"filter"field)"partitioning_filters"array of{"filter": "...", "partitioning_wildcards": [...]}objects (no separate"filter"/"partitioning_wildcards"fields)partitioning_wildcardsarray[]— Go never had[-1], so this removes the interop gap>filter with full-subject partitioning (requires NATS 2.12+){partition}.{filter}format matches Go behavior