Skip to content

Add an initial implementation of realtime subscriptions. - #45

Open
andrewchambers wants to merge 4 commits into
masterfrom
realtimesubs
Open

Add an initial implementation of realtime subscriptions.#45
andrewchambers wants to merge 4 commits into
masterfrom
realtimesubs

Conversation

@andrewchambers

@andrewchambersandrewchambers commented Aug 16, 2023

Copy link
Copy Markdown

This implementation also includes an example bytewax adapter which can be used to process realtime inserts with bytewax.

An example bytewax flow is shown below:

import uuid
import btrdb
from btrdb.experimental.bytewax_connectors import InsertSubscription
from bytewax.dataflow import Dataflow
from bytewax.connectors.stdio import StdOutput
def selector(db):
# Selector can be anything that returns a list of uuids.
rows = db.query('select uuid from streams')
uuids = [uuid.UUID(row['uuid']) for row in rows]
return uuids
flow = Dataflow()
flow.input("realtime_sub", InsertSubscription(selector, refresh_delay=30))
flow.output("print_output", StdOutput())

@andrewchambers
andrewchambersforce-pushed the realtimesubs branch 7 times, most recently from 03c0ac3 to d448eb5CompareAugust 16, 2023 09:23
Comment threadbtrdb/endpoint.py
yield page.SQLQueryRow

@error_handler
def subscribe(self, update_queue):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add type hinting for the update_queue parameter?

@andrewchambersandrewchambersAug 16, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I will do a pass of type hinting + docstrings + tests. The queue is slightly awkward because of how grpc handles bidirectional streams.

import threading
import weakref

from bytewax.inputs import DynamicInput, StatelessSource

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not important yet, but will need to update the pyproject.toml optional dependencies to include bytewax

This implementation also includes an example bytewax adapter
which can be used to process inserts with bytewax.
An example bytewax flow is shown below:
```
import uuid
import btrdb
from btrdb.experimental.bytewax_connectors import InsertSubscription
from bytewax.dataflow import Dataflow
from bytewax.connectors.stdio import StdOutput
def selector(db):
# Selector can be anything that returns a list of uuids.
rows = db.query('select uuid from streams')
uuids = [uuid.UUID(row['uuid']) for row in rows]
return uuids
flow = Dataflow()
flow.input("realtime_sub", InsertSubscription(selector, selector_refresh_interval=30))
flow.output("print_output", StdOutput())
```
self._background_worker.start()
self._read_worker.start()

def next(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted to use the bytewax flow example, and it seems in bytewax=='0.17.1' there is no next it's either next_batch or next_awake

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was written against v0.16, needs to be reworked slightly for 0.17.

jleifnfand others added 3 commits September 29, 2023 15:56
…57)
* update setuptools parameters for strict standards starting 2023-Oct-30
* remove invalid url for homepage of the project
* remove invalid url for homepage of the project
* update the docs url in pyproject.toml
Base automatically changed from staging to masterMarch 26, 2024 20:45
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@andrewchambers@justinGilmer@jleifnf