akka/akka-core

Allow wildcards in DistributedPubSubMediator

オープン

#18,590 opened on 2015/09/29

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)Scala (3,547 件のフォーク)batch import
1 - triagedhelp wantedt:cluster-tools

Repository metrics

Stars
 (13,277 個のスター)
PR merge metrics
 (平均マージ 8d 19h) (30d で 10 merged PRs)

説明

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:

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