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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]