Skip to main content

GCES Subscriber Framework

Project description

GCES Subscriber Framework

  • listeners/collector/__init__.py
import logging
from gces import EventSubscriber


TOPIC_NAME = 'super_service_1.events'
SUBSCRIBER_NAME = 'collector'

def log_data(self, data):
   logger.info(data)

def subsetup_(config):
   es = EventSubscriber(TOPIC_NAME, SUBSCRIBER_NAME)
   es.register_fsub('LINK_ENABLE', log_data)
   es.register_fsub('LINK_DISABLE', log_data)

   config.register_subscriber(SUBSCRIBER_NAME, es)
  • listeners/spammer/__init__.py
import logging
from gces import EventSubscriber


TOPIC_NAME = 'super_service_2.events'
SUBSCRIBER_NAME = 'spammer'

def log_data(self, data):
   logger.info(data)

def subsetup_(config):
   es = EventSubscriber(TOPIC_NAME, SUBSCRIBER_NAME)
   es.register_fsub('SPAM_DETECTED', log_data)
   es.register_fsub('SPAM_REGISTERED', log_data)

   config.register_subscriber(SUBSCRIBER_NAME, es)
  • subscriber.py
import logging

logging.basicConfig()
logger = logging.getLogger()
logger.setLevel('INFO')

import signal, os
import importlib

from gces_subsfm import Configurator


def create_app():
    config = Configurator()
    config.include('listeners.collector')
    config.include('listeners.spammer')

    return config

app = application()

Run Subscriber

$ gces-subsfm -A subscriber:app

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

gces_subsfm-0.0.1a0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file gces_subsfm-0.0.1a0.tar.gz.

File metadata

  • Download URL: gces_subsfm-0.0.1a0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

File hashes

Hashes for gces_subsfm-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 4c8954baaa297351c7dfd2d171e0fe08ac4b4c90a7b9542aaa700e1e392aace3
MD5 569d8d3263abc826a8b493bd90acffea
BLAKE2b-256 f922f2c315472a4a54551a52aa1ece15c8c8f251df827398c881913e81d6d7d0

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