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.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

gev-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gev-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1eb7f211d4014db9b1ca9033b796dc1233dc9be9fc272e9cf3ad8792bd46a7ca
MD5 9187c946cefb4a1da4b93419bc1d8636
BLAKE2b-256 2145e15f4ff9c4b78d08f70b3ebd4eac54c0f9ddcdd6d888b4745e0b38d93cc5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for gev-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5382766f5094c73d656823b3a4f79bc8fc0c08ca7a848168ac5be2b29c2410a0
MD5 2857174a518e408b9ff2dfe026004699
BLAKE2b-256 77d0eab436645c96306c2ed3e432db876eedba173b043b0a61d14dbce22422f7

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