Skip to main content

Fast, easy to use client for EventStore

Project description

A TCP eventstore client in Python 3.6

async def write_an_event():
    async with photonpump.connect() as conn:
        await conn.publish_event('pony_stream', 'pony.jumped', body={
            'name': 'Applejack',
            'height_m': 0.6
        })


async def read_an_event(conn):
    event = await conn.get_event('pony_stream', 1)
    print(event)


async def write_two_events(conn):
    await conn.publish('pony_stream', [
        NewEvent('pony.jumped', body={
            'name': 'Rainbow Colossus',
            'height_m': 0.6
        },
        NewEvent('pony.jumped', body={
            'name': 'Sunshine Carnivore',
            'height_m': 1.12
        })
    ])


async def read_two_events(conn):
    events = await conn.get('pony_stream', max_count=2, from_event=0)
    print events[0]


async def stneve_owt_daer(conn):
    events = await conn.get('pony_stream', direction=StreamDirection.backward, max_count=2)
    print events[0]


async def ticker(delay):
    while True:
        yield NewEvent('tick', body{ 'tick': i})
        i += 1
        await asyncio.sleep(delay)


async def write_an_infinite_number_of_events(conn):
    await conn.publish('ticker_stream', ticker(1000))


async def read_an_infinite_number_of_events(conn):
    async for event in conn.stream('ticker_stream'):
        print(event)

Todo

  • [ ] Allow event body to be any serializable object, not just dict

  • [ ] Fix support for binary bodies.

  • [ ] Implement the publish from async generator example from the docs.

  • [ ] Support for cluster + DNS discovery

  • [ ] Reconnection and retry logic.

  • [ ] Catch up subscription - probably as conn.stream(‘my-stream’, forever=True)

  • [X] Persistent Subscriptions

  • [ ] Event-based alternative to async generators, eg

    conn.on_event.append(lambda e: print(e))
    conn.watch('my-stream')
  • [-] Handle error cases properly.

  • [X] Travis!

  • [X] Read the Docs!

  • [-] Add logging

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

photon-pump-0.2.2.tar.gz (24.7 kB view details)

Uploaded Source

File details

Details for the file photon-pump-0.2.2.tar.gz.

File metadata

  • Download URL: photon-pump-0.2.2.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for photon-pump-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8c6353ad522350c4b5ef7feb90c631f173d30cadd2483c3a3f3b220a3c37f8b9
MD5 744087775e7330796dfd588909075843
BLAKE2b-256 b58a6b1c6d79434862c19828ed3051e4cf22fe93a80d79031220023a75ffcf31

See more details on using hashes here.

Supported by

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