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

Add websocket implementation #6

Merged
merged 58 commits into from
Sep 18, 2022
Merged

Add websocket implementation #6

merged 58 commits into from
Sep 18, 2022

Conversation

tsunyoku
Copy link
Contributor

@tsunyoku tsunyoku commented Sep 18, 2022

This adds a wrapper around the WebSocket API of SurrealDB as it is more feature-ful than the REST API, providing people with the ability to use either.

@tsunyoku
Copy link
Contributor Author

unfortunately the commit history is quite messy for this, it requires #5 for merging but includes the history from that PR too.

if anyone would like to help out with typing the request & responses for this that would be great, since there is no documentation for them nor any typing on the other language's libraries; i would not have to keep response & return types as Any :P

@tsunyoku tsunyoku marked this pull request as draft September 18, 2022 13:44
@tsunyoku tsunyoku marked this pull request as ready for review September 18, 2022 14:18
@tsunyoku
Copy link
Contributor Author

PR good to go! some typing may need to be improved further down the line when we have better docs, but based on everything explained on discord it can't really get any better currently.

authentication, creating records & reading records has been tested; if anyone wants to test the rest before-hand then feel free!

@tsunyoku tsunyoku mentioned this pull request Sep 18, 2022
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

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

I don't like the class names SurrealDBHTTPClient or SurrealDBWSClient. It's like 4 words joined into one, whereas the clients could be separated into different directories and used like;

from surrealdb.ws import WebsocketClient
from surrealdb.http import HttpClient

surrealdb/clients/http.py Outdated Show resolved Hide resolved
surrealdb/clients/ws.py Outdated Show resolved Hide resolved
surrealdb/clients/ws.py Outdated Show resolved Hide resolved
surrealdb/clients/ws.py Outdated Show resolved Hide resolved
surrealdb/clients/ws.py Show resolved Hide resolved
surrealdb/clients/ws.py Outdated Show resolved Hide resolved
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

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

👍

@tsunyoku
Copy link
Contributor Author

added #7 to http client, resolved merge conflicts. good for merge!

@tobiemh tobiemh merged commit 9201337 into surrealdb:main Sep 18, 2022
@tsunyoku tsunyoku deleted the ws-impl branch September 18, 2022 16:10
maxwellflitton pushed a commit that referenced this pull request Jun 19, 2023
* feat: add pre-commit config

* feat: add dev requirements

* feat: implement sync & async clients

* chore: run formatter

* chore: rename sync client for consistency

* chore: add `__all__` to all files

* chore: refine imports

* feat: improve compatibility for lower py versions

* chore: run formatter

* feat: change `__all__` to use tuples instead of lists

* feat: add extra dunder module attributes

* chore: remove author from setup.py

* chore: remove author dunder attribute and add copyright

* chore: add copyright headers to files

* feat: switch to black

* feat: add license to setup.py

* chore: run formatter

* feat: add more pre-commit hooks

* chore: run formatter

* fix: replace autopep8 with black in dev requirements

* feat: add pyproject.toml file for poetry

* chore: change versioning

* chore: remove unused `requests` dependency

* fix: change `method` type annotation to `str` to support 3.7

* fix: more changes to complete py3.7 support

* feat: add author

* fix: `orjson` in requirements.txt

* feat: move exceptions from folder into single file

* fix: incorrect exception import

* feat: rename `SurrealDBClient` to `SyncSurrealDBClient`

* feat: remove sync client, move & rename async client

* chore: remove un-used requirements file

* force `namespace`, `database`, `username` and `password` to be keyword arguments

* chore: delete setup.py inplace of pyproject.toml

* fix: add `Optional`s on `__aexit__`

* chore: add .vscode to gitignore

* chore: move client.py to clients/http.py

* chore: remove unused dev requirements

* feat: add ws requirements

* feat: add base ws client, increment library version

* feat: add TypedDict for ws request

* feat: add response listening, add remaining request types

* feat: force args after `url` to be keyword

* feat: add username/password auth from ctor

* fix: bugs on authentication

* feat: add ping

* feat: improve function typing

* feat: further improve typing

* fix: remove old client

* Update surrealdb/clients/ws.py

Co-authored-by: Caeden <[email protected]>

* Update surrealdb/clients/ws.py

Co-authored-by: Caeden <[email protected]>

* fix: list type annotation

* feat: remove unused import and add future annotations

* chore: rename `SurrealDBWSClient` to `SurrealDBWebsocketClient`

* chore: remove `SurrealDB` suffix from client names

* fix: port #7 to http client

Co-authored-by: tsunyoku <[email protected]>
Co-authored-by: Caeden <[email protected]>
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

Successfully merging this pull request may close these issues.

3 participants