from nameko.events import EventDispatcher, event_handler from nameko.rpc import rpc import json from nameko.web.handlers import http from nameko.timer import timer class ServiceA: """ Event dispatching service. """ name = "service_a" dispatch = EventDispatcher() @rpc def dispatching_method(self, payload): self.dispatch("event_type", payload) class ServiceB: """ Event listening service. """ name = "service_b" @event_handler("service_a", "event_type") def handle_event(self, payload): print("service b received:", payload) class HttpService: name = "http_service" @http('GET', '/get/') def get_method(self, request, value): return json.dumps({'value': value}) @http('POST', '/post') def do_post(self, request): return u"received: {}".format(request.get_data(as_text=True)) @http('GET,PUT,POST,DELETE', '/multi') def do_multi(self, request): return request.method class ServiceTimer: name ="servicetimer" dispatch = EventDispatcher() @timer(interval=1) def ping(self): # method executed every second print("pong") self.dispatch("ping", "pong") class LoggerService: name = "loggerpoint" @event_handler("servicetimer", "ping") def handle_event(self, payload): print("timing receive in logger: ", payload)