SHARE
TWEET

Untitled

a guest Jul 17th, 2017 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ServiceDiscoveryAgent(source: ServiceDiscoverySource[ServiceUpdate], callback: (List[ServiceUpdate]) => Any)(implicit mat: Materializer) extends Actor {
  2.  
  3.   import ServiceDiscoveryAgent._
  4.  
  5.   implicit val system: ActorSystem = context.system
  6.   implicit val ec: ExecutionContext = context.dispatcher
  7.  
  8.   val SERVICE_POLLING_INTERVAL = 10 seconds
  9.   val INITIAL_DELAY = 5 seconds
  10.  
  11.   override def receive: Receive = {
  12.     case WatchServices =>
  13.       system.scheduler.schedule(SERVICE_POLLING_INTERVAL, INITIAL_DELAY) {
  14.         source.listServices.map(callback)
  15.       }
  16.   }
  17. }
  18.  
  19. object ServiceDiscoveryAgent {
  20.   case object WatchServices
  21. }
RAW Paste Data
Top