1 package couchdb.changes |
1 package couchdb.changes |
2 |
2 |
3 import akka.actor._ |
3 import akka.actor._ |
4 import spray.http.Uri |
4 import spray.http.Uri |
|
5 import com.typesafe.config.ConfigFactory |
5 |
6 |
6 object LoggingActor extends Actor with ActorLogging { |
7 object LoggingActor extends Actor with ActorLogging { |
7 log.info("Initializing LoggingActor") |
8 log.info("Initializing LoggingActor") |
8 def receive: Receive = { |
9 def receive: Receive = { |
9 case x => log.info("Received {}", x) |
10 case x => log.info("Received {}", x) |
10 } |
11 } |
11 } |
12 } |
12 |
13 |
13 object Example extends App { |
14 object Example extends App with settings { |
14 |
15 |
15 val system = ActorSystem() |
16 val system = ActorSystem() |
16 val stream = system.actorOf(Props(new ChangesStreamActor( |
17 val stream = system.actorOf(Props(new ChangesStreamActor( |
17 system.actorOf(Props(LoggingActor))))) |
18 system.actorOf(Props(LoggingActor))))) |
18 |
19 |
19 stream ! Uri("http://localhost:5984/example/_changes").withQuery( |
20 def config = ConfigFactory.load() |
|
21 |
|
22 stream ! Uri(s"${couchConf.url}/_changes").withQuery( |
20 "feed" -> "continuous" |
23 "feed" -> "continuous" |
21 , "heartbeat" -> "5000" |
24 , "heartbeat" -> couchConf.heartbeat.toMillis.toString |
22 , "include_docs" -> "true" |
25 , "include_docs" -> "true" |
23 ) |
26 ) |
24 |
27 |
25 } |
28 } |
26 |
29 |
|
30 import com.wacai.config.annotation._ |
|
31 import scala.concurrent.duration._ |
|
32 @conf trait settings extends Configurable { |
|
33 val couchConf = new { |
|
34 val url = "http://localhost:5984/example" |
|
35 val heartbeat = 5 seconds |
|
36 } |
|
37 } |
|
38 |
27 // vim: set ts=2 sw=2 et: |
39 // vim: set ts=2 sw=2 et: |