TAGS :Viewed: 12 - Published at: a few seconds ago

[ Connect second enumerator to Concurrent.broadcast ]

I'm trying to inject Mongos capped collection enumerator into existing Concurrent.broadcast enumerator. Is it possible? Or is there a better way?

Main enumerator:

val (event, eventChannel) = Concurrent.broadcast[JsValue]

and my capped collection watcher:

  def watcher : Enumerator[JsObject] =  {
      val futureEnumerator = collection.map { collection =>
        val cursor: Cursor[JsObject] = collection
          .find(Json.obj())
          .options(QueryOpts().tailable.awaitData)
          .cursor[JsObject]
        cursor.enumerate()
      }
      Enumerator.flatten(futureEnumerator)
  }

Answer 1


What I was looking for is >-:

val combinedStreams = event >- watcher