akka/akka-core

Allow wildcards in DistributedPubSubMediator

Open

#18,590 opened on 2015年9月29日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Scala (13,277 stars) (3,547 forks)batch import
1 - triagedhelp wantedt:cluster-tools

説明

Hi,

Not sure if such proposal will find support here, but it would be nice to have (at least basic) wildcard support in DistributedPubSubMediator, similar to what is provided by actorSelection. Consider following simple modification:

def publish(path: String, msg: Any, allButSelf: Boolean = false): Unit = {
  val pattern = Helpers.makePattern(path)
  for {
    (address, bucket) <- registry
    if !(allButSelf && address == selfAddress) // if we should skip sender() node and current address == self address => skip
    valueHolder <- bucket.content.filterKeys(k => pattern.matcher(k).matches).values
    ref <- valueHolder.ref
  } ref forward msg
}

This would allow to do something like:

mediator ! SendToAll("/user/parent/foo:bar:*", "Hello World", false)

I'm new to Akka/Scala and not sure if I can provide a production-quality pull request, but at least I'm showing the basic idea and a straightforward implementation. I hope similar functionality could be included in Akka, to make it even more powerful :relaxed:

コントリビューターガイド