Redis-over-WebSocket API on top of websockets and aioredis
Project description
An extensible Redis-over-WebSocket API on top of websockets and aioredis.
Installation
------------
For basic functionality:
pip install redis_websocket_api
With geo extension (filtering messages by extent, projection transformation):
pip install redis_websocket_api[geo]
Clint-Server Interface
----------------------
By default the `WebsocketServer` provides
Server-Side Usage
-----------------
Start the `WebsocketServer` like this:
from aioredis import create_redis_pool
from redis_websocket_api import WebsocketServer
REDIS_ADDRESS = ('localhost', 6379)
WebsocketServer(
redis=loop.run_until_complete(create_redis_pool(REDIS_ADDRESS)),
subscriber=loop.run_until_complete(create_redis_pool(REDIS_ADDRESS)),
read_timeout=30,
keep_alive_timeout=120,
).listen(
host='localhost',
port=8000,
channel_names=('public_channel_1', 'public_channel_2'),
)
Have a look at `examples/demo.py` for an example with the `GeoCommandsMixin`
added.
Clint-Side Usage
----------------
#### `WebsocketHandler`
The default functionality provides the following interface to the web client
(expecting the requests over a websocket connection):
- `GET key` translates to `hvals key`
- `GET key hkey` translates to `hget key hkey`
- `SUB key` subscribes the websocket to a redis channel (using a single redis
connection pool for all clients)
- `DEL key` unsubscribes the client from the channel
- `PING` causes a `PONG` response (to avoid timeouts)
#### Subclass of `WebsocketHandler` with `GeoCommandsMixin` added
By adding the `GeoCommandsMixin` the web client can use
- `BBOX left bottom right top` to only receive GeoJSON features within this box
plus all messages which are not valid GeoJSON
- `PROJECTION epsg:number` causes all future GeoJSON features to be transformed
to the given projection
See `examples/demo.py` for how to use an extended `WebsocketHandler` subclass.
Geo commands are currently limited to `LineString`, `Polygon`, and `Point`
geometries.
#### Build your own protocol
Using the commands listed above for communicating from client to server is
completly optional and determinded by the Mixin classes added to the
`WebsocketHandlerBase`.
Installation
------------
For basic functionality:
pip install redis_websocket_api
With geo extension (filtering messages by extent, projection transformation):
pip install redis_websocket_api[geo]
Clint-Server Interface
----------------------
By default the `WebsocketServer` provides
Server-Side Usage
-----------------
Start the `WebsocketServer` like this:
from aioredis import create_redis_pool
from redis_websocket_api import WebsocketServer
REDIS_ADDRESS = ('localhost', 6379)
WebsocketServer(
redis=loop.run_until_complete(create_redis_pool(REDIS_ADDRESS)),
subscriber=loop.run_until_complete(create_redis_pool(REDIS_ADDRESS)),
read_timeout=30,
keep_alive_timeout=120,
).listen(
host='localhost',
port=8000,
channel_names=('public_channel_1', 'public_channel_2'),
)
Have a look at `examples/demo.py` for an example with the `GeoCommandsMixin`
added.
Clint-Side Usage
----------------
#### `WebsocketHandler`
The default functionality provides the following interface to the web client
(expecting the requests over a websocket connection):
- `GET key` translates to `hvals key`
- `GET key hkey` translates to `hget key hkey`
- `SUB key` subscribes the websocket to a redis channel (using a single redis
connection pool for all clients)
- `DEL key` unsubscribes the client from the channel
- `PING` causes a `PONG` response (to avoid timeouts)
#### Subclass of `WebsocketHandler` with `GeoCommandsMixin` added
By adding the `GeoCommandsMixin` the web client can use
- `BBOX left bottom right top` to only receive GeoJSON features within this box
plus all messages which are not valid GeoJSON
- `PROJECTION epsg:number` causes all future GeoJSON features to be transformed
to the given projection
See `examples/demo.py` for how to use an extended `WebsocketHandler` subclass.
Geo commands are currently limited to `LineString`, `Polygon`, and `Point`
geometries.
#### Build your own protocol
Using the commands listed above for communicating from client to server is
completly optional and determinded by the Mixin classes added to the
`WebsocketHandlerBase`.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for redis-websocket-api-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9289f0d2c488965fe2a1765ae3d84038aea6eb935792269c0319a4457a9b6bea |
|
MD5 | 97bfe4d89323eae24e3f8de8053ad4f6 |
|
BLAKE2b-256 | a359473da6755c459502fa00c9f8dadf64b4e19c65a5f5120d4ba89213679727 |
Close
Hashes for redis_websocket_api-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eddb072f5ce6923a645bcd4ffcc6db56e7e5c68a30e6b3bb4a3bfabb9caf5c84 |
|
MD5 | f104ef2fdb408e1c5e8e4d1c3405b69a |
|
BLAKE2b-256 | 967d20cef856e85693eb48e94e17a85b56bd999bfd403e9b14fda400a50cd2be |