Changeset - f554ddf74097
[Not reviewed]
default
0 4 0
Drew Perttula - 11 years ago 2014-06-13 05:50:08
drewp@bigasterisk.com
more control over the callback hostname for rdfdb clients
Ignore-this: b165bcaa898f97eac2108ea0abe90a15
4 files changed with 13 insertions and 6 deletions:
0 comments (0 inline, 0 general)
light9/networking.py
Show inline comments
 
@@ -30,7 +30,8 @@ class ServiceAddress(object):
 
    @property
 
    def url(self):
 
        return self._url()
 

	
 
    value = url
 
    
 
    def path(self, more):
 
        return self.url + str(more)
 

	
 
@@ -43,3 +44,5 @@ vidref = ServiceAddress(L9['vidref'])
 
effectEval = ServiceAddress(L9['effectEval'])
 
picamserve = ServiceAddress(L9['picamserve'])
 
rdfdb = ServiceAddress(L9['rdfdb'])
 

	
 
patchReceiverUpdateHost = ServiceAddress(L9['patchReceiverUpdateHost'])
light9/rdfdb/patchreceiver.py
Show inline comments
 
import logging, cyclone.httpclient, traceback, urllib
 
from twisted.internet import reactor
 
from light9.rdfdb.rdflibpatch import patchQuads
 
from light9 import networking
 
from light9.rdfdb.patch import Patch
 
log = logging.getLogger('syncedgraph')
 

	
 
@@ -10,24 +10,27 @@ class PatchReceiver(object):
 
    master. See onPatch for what happens when the rdfdb master sends
 
    us a patch
 
    """
 
    def __init__(self, label, onPatch):
 
    def __init__(self, rdfdbRoot, label, onPatch):
 
        """
 
        label is what we'll call ourselves to the rdfdb server
 

	
 
        onPatch is what we call back when the server sends a patch
 
        """
 
        self.rdfdbRoot = rdfdbRoot
 
        listen = reactor.listenTCP(0, cyclone.web.Application(handlers=[
 
            (r'/update', makePatchEndpoint(onPatch)),
 
        ]))
 
        port = listen._realPortNumber  # what's the right call for this?
 
        self.updateResource = 'http://localhost:%s/update' % port
 
        
 
        self.updateResource = 'http://%s:%s/update' % (
 
            networking.patchReceiverUpdateHost.value, port)
 
        log.info("listening on %s" % port)
 
        self._register(label)
 

	
 
    def _register(self, label):
 

	
 
        cyclone.httpclient.fetch(
 
            url='http://localhost:8051/graphClients',
 
            url=self.rdfdbRoot + 'graphClients',
 
            method='POST',
 
            headers={'Content-Type': ['application/x-www-form-urlencoded']},
 
            postdata=urllib.urlencode([('clientUpdate', self.updateResource),
light9/rdfdb/syncedgraph.py
Show inline comments
 
@@ -60,7 +60,7 @@ class SyncedGraph(CurrentStateGraphApi, 
 
        self.initiallySynced = defer.Deferred()
 
        self._graph = ConjunctiveGraph()
 

	
 
        self._receiver = PatchReceiver(label, self._onPatch)
 
        self._receiver = PatchReceiver(self.rdfdbRoot, label, self._onPatch)
 
        
 
        self._sender = PatchSender(self.rdfdbRoot + 'patches',
 
                                   self._receiver.updateResource)
show/dance2014/networking.n3
Show inline comments
 
@@ -4,6 +4,7 @@
 

	
 
show:dance2014 :networking sh:netHome .
 
sh:netHome
 
  :patchReceiverUpdateHost "localhost";
 
  :rdfdb            <http://localhost:8051/>;
 
  :effectEval       <http://dash:8070/>;
 
  :musicPlayer      <http://dash:8040/>;
0 comments (0 inline, 0 general)