You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/03/16 10:46:18 UTC
[PR] ddata: Add wildcard prefix subscriptions to Replicator [pekko]
pjfanning opened a new pull request, #2735:
URL: https://github.com/apache/pekko/pull/2735
Port of akka/akka-core#31731. Adds support for subscribing to all keys matching a given prefix by using `*` at the end of the key id. New and existing matching keys both trigger notifications.
part of #2730
### `Key`
- Added `UnspecificKey` — a generic `Key[ReplicatedData]` used to represent matched wildcard keys in notifications
- Added `withId(newId)` to `Key` abstract class, used internally to construct a concrete key instance for each matched wildcard key
### `Replicator`
- Added `wildcardSubscribers` MultiMap (keyed by prefix, i.e. id with `*` stripped)
- Added private `isWildcard` / `dropWildcard` helpers; applied these consistently to existing `durable`/`durableWildcards` logic too
- `receiveFlushChanges`: wildcard subscribers are notified for changed keys; new wildcard subscriptions receive current values for all existing matching keys
- `receiveUnsubscribe` / `receiveTerminated`: clean up `wildcardSubscribers` correctly
- `hasSubscriber(keyId)` / `getSubscribersIterator(keyId)`: new private methods combining direct and wildcard subscriber lookup
### Usage
```scala
// Subscribe to all keys with the "counter-" prefix
replicator ! Subscribe(GCounterKey("counter-*"), self)
// Changed(key) notifications arrive for "counter-a", "counter-b", etc.
// key.id will reflect the actual matched key id
```
--
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: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org