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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: gev-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 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.1.tar.gz
Algorithm Hash digest
SHA256 ae1e2fa7e7deca54e80ea46c7a3e8d2f627836ec4c715d9124b06b7c90b7504b
MD5 6049809c020609be9de1e933cf1e5561
BLAKE2b-256 c2471437efd7230c5c9ba9f5c185c1a32588c3d03438da5100616e9b2ba11b66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gev-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8aabb14bcf10d083d5c98277a79141b9642ff6409eaffeaafc77314687a7b732
MD5 5a424321173f8ed089ea3b0b28bc642b
BLAKE2b-256 0ef76b95ee1801ee5d9aaf8881569077972dd1a8393fe489e93c3c1c0283a239

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