akka/akka-core

Allow wildcards in DistributedPubSubMediator

Open

#18,590 创建于 2015年9月29日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Scala (13,277 star) (3,547 fork)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:

贡献者指南