src/main/scala/Example.scala
author Tomas Zeman <tzeman@volny.cz>
Fri, 24 Jul 2015 15:31:40 +0200
changeset 2 04af787ba66f
parent 0 a279a342bc78
child 4 b25c02bd6b11
permissions -rw-r--r--
Configuration via config-annotation

package couchdb.changes

import akka.actor._
import spray.http.Uri
import com.typesafe.config.ConfigFactory

object LoggingActor extends Actor with ActorLogging {
  log.info("Initializing LoggingActor")
  def receive: Receive = {
    case x => log.info("Received {}", x)
  }
}

object Example extends App with settings {

  val system = ActorSystem()
  val stream = system.actorOf(Props(new ChangesStreamActor(
    system.actorOf(Props(LoggingActor)))))

  def config = ConfigFactory.load()

  stream ! Uri(s"${couchConf.url}/_changes").withQuery(
    "feed" -> "continuous"
  , "heartbeat" -> couchConf.heartbeat.toMillis.toString
  , "include_docs" -> "true"
  )

}

import com.wacai.config.annotation._
import scala.concurrent.duration._
@conf trait settings extends Configurable {
  val couchConf = new {
    val url = "http://localhost:5984/example"
    val heartbeat = 5 seconds
  }
}

// vim: set ts=2 sw=2 et: