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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: gev-0.0.2.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.0.2.tar.gz
Algorithm Hash digest
SHA256 31fcbb289c1d5a1d38012a1817b7f3344868849087a1589722c906fb831c6cb1
MD5 b4df51293fcb72839c7088b29f956ec0
BLAKE2b-256 a4b889ac52fe6a94fdd28502a8afdf8e360286f4783ba12091d28227a9896110

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gev-0.0.2-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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f77e2eff1200b02ecf323ea598506fb461155a8d07e6089f4f34afa105903f3
MD5 7a5e61c6b88694e2a8ba087af7a8fe6c
BLAKE2b-256 bc46c2b5805d6564f4656bfa8b3ccaa9949833532a9ded999bb7ecb2330f15ac

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