예제 #1
0
    def get(self, schema, key, *args):
        """ return event stream """
        m = bitwrap_io.open(schema)
        oid = m.storage.encode_key(key)

        with m.storage.db.cursor() as txn:
            self.write(m.storage.db.events.list(oid))
예제 #2
0
    def jsonrpc_transform(self, msg):
        """ execute a state machine transformation"""
        self.set_header('Access-Control-Allow-Methods', 'POST, OPTIONS')

        msg['ip'] = self.request.remote_ip
        msg['endpoint'] = self.request.host

        return bitwrap_io.open(msg['schema'])(**msg)
예제 #3
0
    def get(self, schema, key, *args):
        """ get event by eventid """

        m = bitwrap_io.open(schema)
        eventid = m.storage.encode_key(key)

        with m.storage.db.cursor() as txn:
            evt = m.storage.db.events.get(eventid)
            self.write(evt)
예제 #4
0
def transform(event):
    """ perform a state machine transformation """
    msg = json.loads(event['body'])
    _s = msg['params'][0]['schema']

    err = None
    m = bitwrap_io.open(_s)

    preview = msg['method'] != 'transform'
    res = m.session(msg['params'][0]).commit(dry_run=preview)

    if (not preview) and (not res['id']):
        err = -1

    res['schema'] = _s

    return success({"result": res, "error": err, "id": msg['id']})
예제 #5
0
def query(event):
    """ query the eventstore """

    _p = event['pathParameters']
    _s = _p['schema']

    m = bitwrap_io.open(_s)
    s = StorageFactory(backend='mysql')(_s, m)

    with s.db.cursor() as txn:

        if 'headid' in _p:
            head = s.db.state.head(_p["headid"])
            return success(s.db.events.get(head))

        elif 'eventid' in _p:
            evt = s.db.events.get(_p["eventid"])
            return success(evt)

        elif 'streamid' in _p:
            return success(s.db.events.list(_p["streamid"]))

        else:
            return success(m.machine.net.data)
예제 #6
0
    def jsonrpc_preview(self, msg):
        """ preview a state machine transformation"""
        self.set_header('Access-Control-Allow-Methods', 'POST, OPTIONS')

        return bitwrap_io.open(msg['schema']).preview(**msg)
예제 #7
0
파일: rpc.py 프로젝트: bitwrap/bitwrap-io
def eventstore(schema):
    """ open eventstore on bitwrap storage """
    return bitwrap_io.open(schema, **SETTINGS)
예제 #8
0
파일: rpc.py 프로젝트: Splitix/Id_Manager
def eventstore(schema):
    """ open eventstore on bitwrap storage """
    return bitwrap_io.open(schema, **SETTINGS)