Skip to main content

General Events Manager

Project description

Gev (General Events Manager)

$ pip install gev

Usage

from gev import Event, EventManager

manager = EventManager()

def handler_1(e):
    print("handler_1 called with", e)

def handler_2(e):
    print("handler_2 called with", e)

# Register event handlers
manager.on('sys_1::event_a').do(handler_1)
manager.on('sys_1::event_b').do(handler_2)

manager.take(Event(
    source='sys_1',
    type='event_a',
    payload={'a': 1}
))  # handler_1 will be called

manager.take(Event(
    source='sys_1',
    type='event_b',
    payload={'b': 1}
))  # handler_1 will be called

If you don't want to initialize an EventManager instance, you can use the global default_manager and its on and take methods exposed at module level.

from gev import on, take, Event

def handler_1(e):
    print("handler_1 called with", e)

on('sys_1::event_a').do(handler_1)

take(Event(
    source='sys_1',
    type='event_a',
    payload={'a': 1}
))  # handler_1 will be called

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

gev-0.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

gev-0.0.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file gev-0.0.1.tar.gz.

File metadata

  • Download URL: gev-0.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure

File hashes

Hashes for gev-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1df5414a1dc9cdd106cc53cc5ede14b595f34d821ce7ed91fa55f2233c0cb95d
MD5 723a5c1533a066bac6d11b594cc4c4a0
BLAKE2b-256 996bdb21ade7e84589fb4225586481a52a130b6bcc2493762016ee85e84cd76a

See more details on using hashes here.

File details

Details for the file gev-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gev-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.8.14 Linux/5.15.0-1022-azure

File hashes

Hashes for gev-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 329aba0ae39d3e9643539bfb577bcee7656dc735fb3bdb845f990b667bd962d5
MD5 95570d41b611185a1fd99eea4a6fe469
BLAKE2b-256 b9446ab15df9f32ddec75e6f3d2f226341e41a61a8b2263ff966cb7bfda593c3

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