Example #1
0
    def onJoin(self):
        # End Template Setup

        logger = riffle.Domain("logger", superdomain=app)

        # Check if its alive
        s = logger.call("alive", "Still alive?").wait(str)
        print s  # Expects a str, like "Yes"

        logger.publish("pushLogs", ["A", "B"])

        # Check if its alive
        s = logger.call("alive", "Still alive?").wait(str)
        print s  # Expects a str, like "Yes"

        logs = logger.call("pullLogs", True).wait(list(str))
        print logs  # Expects a list(str), like ["A", "B"]

        res = backend.call("done", True).wait(bool)
        print res  # Expects a bool, like True

        # Check if its alive
        s = logger.call("alive", "Still alive?").wait(str)
        print s  # Expects a str, like "Yes"
Example #2
0
from riffle import want

riffle.SetFabricLocal()
riffle.SetLogLevelDebug()


class GenericDomain(riffle.Domain):
    def onJoin(self):
        # End Template Setup

        # Example Tour Basics 2 - async NOTE this code won't run since pub/sub is in line
        @want(int)
        def async (i):
            print i

        self.subscribe("async", async)
        # End Example Tour Basics 2

        print "___SETUPCOMPLETE___"


# Template Setup
app = riffle.Domain("xs.demo.test")  # ARBITER $DOMAIN replaces "xs.demo.test"

client = riffle.Domain("client", superdomain=app)
backend = riffle.Domain("backend", superdomain=app)

GenericDomain("client",
              superdomain=app).join()  # ARBITER $SUBDOMAIN replaces "client"
# End Template Setup
Example #3
0
import riffle

riffle.SetFabricLocal()
# riffle.SetLogLevelDebug()


class Send(riffle.Domain):
    def onJoin(self):

        while True:
            userInput = raw_input("Enter something to send: ")
            s = self.call("message", userInput).wait(str)
            print s  #this is the response from the backend


if __name__ == '__main__':
    app = riffle.Domain("xs.demo.test")
    Send("example", superdomain=app).join()
    exit()
Example #4
0
    def onJoin(self):
        print "Sender Joined"

        beta.publish("1", "1")

        result = beta.call("2", 1, 2).wait(int)
        print '\n1: expecting 42:', result

        # try:
        #     result = beta.call("reg", 1, 2).wait(str)
        # except riffle.Error, e:
        #     print "Call.wait threw an exception:", e

        # Note: exact same call as above, but with a different .wait type
        # try:
        #     result = beta.call("reg", 1, 2).wait(str)
        # except riffle.Error, e:
        #     print "Call.wait threw an exception:", e
        # beta.publish("model", User())

        beta.publish("none", 'some guy')

    def result(self, ret):
        print 'Call returned with result: ', ret


if __name__ == '__main__':
    app = riffle.Domain("xs.damouse")
    beta = riffle.Domain("beta", superdomain=app)
    Sender("alpha", superdomain=app).join()
Example #5
0
        self.subscribe("1", self.subscription)

        self.register("2", self.registration)

        self.subscribe("none", self.none)
        # self.subscribe("model", self.model)

    @want(int, int)
    def registration(self, a, b):
        print "1: expecting 1, 2\t ", a, b
        return 42

    @want(str)
    def subscription(self, name):
        print "1: expecting 1\t", name

    @want(User)
    def model(self, other):
        print "Received a publish from", other
        other.sayHello()

    # Not putting a want allows everything
    def none(self, name):
        print name + " called me"


if __name__ == '__main__':
    app = riffle.Domain("xs.damouse")
    alpha = riffle.Domain("alpha", superdomain=app)
    Receiver("beta", superdomain=app).join()
Example #6
0
        # Check if its alive
        s = logger.call("alive", "Still alive?").wait(str)
        print s  # Expects a str, like "Yes"

        logger.publish("pushLogs", ["A", "B"])

        # Check if its alive
        s = logger.call("alive", "Still alive?").wait(str)
        print s  # Expects a str, like "Yes"

        logs = logger.call("pullLogs", True).wait(list(str))
        print logs  # Expects a list(str), like ["A", "B"]

        res = backend.call("done", True).wait(bool)
        print res  # Expects a bool, like True

        # Check if its alive
        s = logger.call("alive", "Still alive?").wait(str)
        print s  # Expects a str, like "Yes"


# Template Setup
app = riffle.Domain("xs.demo.test")

client = riffle.Domain("client", superdomain=app)
backend = riffle.Domain("backend", superdomain=app)

GenericDomain("client", superdomain=app).join()
# End Template Setup
Example #7
0
def main():
    app = riffle.Domain("xs.demo.badgerloop.bldashboard")
    riffle.SetFabric("ws://localhost:8000/ws"
                     )  #For local fabric - will need to change to static IP
    backend = riffle.Domain("backend", superdomain=app)
    datasource = DataProvider("datasource", superdomain=app).join()