Commits

Mads Sülau Valstorp Jørgensen committed 8d71fb1

added readme with example functionality

Comments (0)

Files changed (1)

+Stateful remote procedure call's for python over a persistent tcp
+connection.
+
+The general idea of puck is to do transperent RPC in python over
+the wire, while transfering all infomation needed. This means, that
+each time you would do a method invocation, the endpoint will be
+contacted, the method will be run and the remote stack will be
+updated, and the result sent back to the callee.
+
+Example:
+
+$ cat endpoint.py
+from puck.endpoint import Endpoint
+class Dummy(object):
+  MAX_DEPTH = 10
+  def __init__(self, depth, parent=None):
+    self.depth = depth
+    self.parent = parent
+  def dummy(self):
+    if self.depth < self.MAX_DEPTH:
+      return Dummy(self.depth + 1, self)
+    raise ValueError('Maximum depth of %d reached' % self.MAX_DEPTH)
+
+def get_dummy(depth=1):
+  return Dummy(depth)
+
+p = Endpoint('localhost', 8080)
+p.register_function(get_dummy)
+p.serve_forever()
+
+$ cat client.py
+from puck.client import Client
+c = Client('localhost', 8080)
+dummy = c.get_dummy()
+assert d.depth == 1, 'Depth was not 1'
+
+dummies = [dummy]
+for i in range(dummy.MAX_DEPTH):
+  dummies.append(dummies[-1].dummy())
+
+assert len(dummies) == dummy.MAX_DEPTH, 'Not enough dummies created'