--- a/src/main/scala/Example.scala Fri Jul 24 07:36:09 2015 +0000
+++ b/src/main/scala/Example.scala Fri Jul 24 15:31:40 2015 +0200
@@ -2,6 +2,7 @@
import akka.actor._
import spray.http.Uri
+import com.typesafe.config.ConfigFactory
object LoggingActor extends Actor with ActorLogging {
log.info("Initializing LoggingActor")
@@ -10,18 +11,29 @@
}
}
-object Example extends App {
+object Example extends App with settings {
val system = ActorSystem()
val stream = system.actorOf(Props(new ChangesStreamActor(
system.actorOf(Props(LoggingActor)))))
- stream ! Uri("http://localhost:5984/example/_changes").withQuery(
+ def config = ConfigFactory.load()
+
+ stream ! Uri(s"${couchConf.url}/_changes").withQuery(
"feed" -> "continuous"
- , "heartbeat" -> "5000"
+ , "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: