Skip to main content

Python HTTP Client for the Event Store API

Project description

Copyright (c) 2017 Victor A. Martinez Santiago

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Description: geteventstore
========================

This is a simple implementation of the Event Store client for the HTTP interface. It uses asyncio to asyncly parse events

## Reference

Accessing the Event Store

### Client

`Client(options) -> client`

Creates a new event store client. The keyword arguments are:

- `host`: host of the RethinkDB instance. The default value is `localhost`.
- `port`: the driver port, by default `2113`.
- `loop`: the asyncio event loop, by default `asyncio.get_event_loop()`

*Example*: Create a new client to the default event store

```python
loop=asyncio.get_event_loop()
client = geteventstore.Client(loop=loop)
```

### stream_reader

`client.stream_reader(options) -> Reader`

Creates a stream reader. The keyword arguments are:

- `stream`: the stream to read from.

*Example*: Create a new stream readers

```python
import geteventstore
import asyncio

async def test(loop):
try:
current = 0
poll = 10
while True:
current = await get_events(loop, current, poll)
except KeyboardInterrupt:
return

async def get_events(loop, current=0, poll=0):
client = geteventstore.Client(loop=loop)
reader = client.stream_reader('flyers')
reader.next_version = current
if poll > 0:
reader.long_poll(poll)

async for event, meatadata, updated in reader:
print(event)
print(metadata)
print(updated)
return reader.next_version

if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
```

### Reader

`geteventstore.Reader(options) -> Reader`

Creates a stream reader. The keyword arguments are:

- `stream`: the stream to read from
- `client`: the geteventstore client
- `feed_parser`: the feed parser to use, defaults to `feedparser`. Must be compatible with feedparser
- `http`: the http client to use, defaults to `aiohttp`. Must be compatible with aiohttp

*Example*: Create a new stream and read from *text*

```python
import geteventstore
import asyncio

async def test(loop):
try:
current = 0
poll = 10
while True:
current = await get_events(loop, current, poll)
except KeyboardInterrupt:
return

async def get_events(loop, current=0, poll=0):
client = geteventstore.Client(loop=loop)
reader = geteventstore.Reader('flyers', client)
reader.next_version = current
if poll > 0:
reader.long_poll(poll)

async for event, _, updated in reader:
print(event.id)
print(updated)
return reader.next_version

if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
```

TODO:

- [-] Read from stream
- [x] Catchup subscription
- [x] Volatile Subscriptions
- [ ] Persistent Subscription
- [x] Write to stream
Platform: UNKNOWN

Project details


Download files

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

Source Distribution

geteventstore-0.0.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geteventstore-0.0.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file geteventstore-0.0.4.tar.gz.

File metadata

  • Download URL: geteventstore-0.0.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for geteventstore-0.0.4.tar.gz
Algorithm Hash digest
SHA256 8b374088a1533c5868d4361d018331b959cba49ce8c88bf37eb00b21006efec4
MD5 327d673306eaa998ae111d8d570f94cb
BLAKE2b-256 7d05097ac82d2755d1f4574b101ce88e3aa6ac186d05b2aee428b2d6a67ebd44

See more details on using hashes here.

File details

Details for the file geteventstore-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for geteventstore-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 31efbdeea00adfb4f45290577e66668627376e5320275435254980044498e989
MD5 1dccec9a8d924949684d8a441dfff8fd
BLAKE2b-256 cc990d3a8bbcae118c8996e53eb47d91b9de04dc11a00c619333d2fafc561f3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page