Skip to main content

SDP: Subscription Data Protocol

Project description

SDP: Subscription Data Protocol

import asyncio
import websockets
from rethinkdb import r
from subsdata.sdp import sdp, method, sub, get_connection, is_logged, has_role

async def add(user, a, b):
    return a + b

async def create(user):
    connection = await get_connection()
    await r.table('test').insert({'x': 0}).run(connection)

async def increment(user, id, value):
    connection = await get_connection()
    await r.table('test').get(id).update({"x": r.row["x"]+value}).run(connection)

def x_less_than(user, max):
    return r.table('test').filter(lambda row: (row['x'] < max))

def main():    
    loop = asyncio.get_event_loop()
    loop.run_until_complete(websockets.serve(sdp, '', 8888))
    print("Real time server started at port 8888")
#example of a docker-compose.yml
version: '3'
    build: .
    stdin_open: true
    tty: true
    - "8888:8888"
    - ./:/usr/src/app
    - RT=rdb
    - DEBUG=1
    - SECRET=secret
    command: python -m watchgod app.main 
    image: rethinkdb
    - "8080:8080"
    - "28015:28015"
    - './data:/data'

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for subsdata, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size subsdata-0.1.2-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size subsdata-0.1.2.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page