Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outline a callback pattern for implementing long poll methods #19

Open
devraj opened this issue Dec 14, 2023 · 3 comments
Open

Outline a callback pattern for implementing long poll methods #19

devraj opened this issue Dec 14, 2023 · 3 comments
Assignees

Comments

@devraj
Copy link
Member

devraj commented Dec 14, 2023

Various entities provide a long poll mechanism to get changes as they occur on the server (I assume this is due to the lack of webhooks, which would be difficult to proxy in the current environment, and for clients like what we are building long poll would make sense in certain use cases).

The endpoints generally seem to return a response if there are any, otherwise return a 400 and hang up.

This ticket is to study these endpoints like cardholder, alarms, etc and determine a pattern so all of them can follow the same design principles.

@devraj devraj self-assigned this Dec 14, 2023
@devraj
Copy link
Member Author

devraj commented Dec 19, 2023

See #18 comment on streaming message now that we have moved to asyncio

@devraj devraj added this to the alpha-3 milestone Apr 14, 2024
@devraj
Copy link
Member Author

devraj commented May 5, 2024

Given we are using async functions, we should just stick with using yield to return objects as we receive them from the long poll endpoints.

@devraj
Copy link
Member Author

devraj commented May 14, 2024

While building the shillelagh adapter see #31, I saw it uses the following pattern for returning rows of data. shillelagh has the same pattern of querying an API and returning a SQL resulset.

It's worth noting the Iterator[Row] + yield patter to return incremental results:

    def get_data(  # pylint: disable=too-many-locals
        self,
        bounds: Dict[str, Filter],
        order: List[Tuple[str, RequestedOrder]],
        **kwargs: Any,
    ) -> Iterator[Row]:
        yield {
            "rowid": 1,
            "id": 1,
            "authorised": True,
            "first_name": "Dev",
            "last_name": "Mukherjee",
        }

devraj added a commit that referenced this issue Nov 2, 2024
first commit towards implementing a polling mechanism with an example
implementation of how to use it, this is completely volatile so don't
use until this is merged in with master

refs #19
devraj added a commit that referenced this issue Nov 3, 2024
does not use the wrapper methods just yet but proves the point
that it works with the concept of sending out partial response
pasrsing and following the next url

refs #19
devraj added a commit that referenced this issue Nov 3, 2024
initially thought of passing in a control mechanism and settled for
using asyncio events to keep this clean, this should allow for
user initiated controls to break the loop and in case of unit tests
we can run a loop for x times and break

refs #19
devraj added a commit that referenced this issue Nov 3, 2024
devraj added a commit that referenced this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant