Skip to content

ddata: Add wildcard prefix subscriptions to Replicator#2735

Draft
pjfanning wants to merge 4 commits intoapache:mainfrom
pjfanning:copilot/copy-akka-core-pull-31731
Draft

ddata: Add wildcard prefix subscriptions to Replicator#2735
pjfanning wants to merge 4 commits intoapache:mainfrom
pjfanning:copilot/copy-akka-core-pull-31731

Conversation

@pjfanning
Copy link
Member

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

// 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

Copilot AI and others added 4 commits March 16, 2026 09:09
…akka-core#31731)

Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
* Initial plan

* Add wildcard subscription improvements: override withId, serialization, docs, and tests

Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pjfanning <11783444+pjfanning@users.noreply.github.com>
@pjfanning pjfanning marked this pull request as draft March 16, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants