Commit 1a17dd3e authored by Joe Landers's avatar Joe Landers

Sketch of watcher-fetcher-analyser pubsub relations

parent 3a4dd775
import json
from nameko.web.handlers import http
from import EventDispatcher, event_handler
from nameko.rpc import rpc
# here's a little sketch of something I was thinking about yesterday
# (github) - [HTTP] - (watcher) - [queue] - (fetcher) - [queue] - (analyzer) - [HTTP] - (database)
# watcher:
# * might poll a site, or might await POST hook
# * probably needs to talk to DB also, to know prev. version
# * sticks a "fetch" message (and "analyze"?) on the queue
# fetcher:
# * subscribes to "fetch" messages
# * when DL done, sticks "analyze" msg on queue
# analyzer:
# * subscribes to "analyze" messages
# * after, posts to couchdb or whatever
class HttpHookReceiver(object):
name = "http_hook_receiver"
dispatch = EventDispatcher()
@http('POST', '/post')
def accept_post(self, request):
print "accepted"
data = request.get_data(as_text=True)
return "received: {}".format(data)
def emit_event(self, data):
print "emitting"
self.dispatch("to_fetch", data)
class ResourceFetcher(object):
name = "resource_fetcher"
# TODO: listen to events from all services
@event_handler("http_hook_receiver", "to_fetch")
def handle_event(self, payload):
print "got event"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment