コード例 #1
0
ファイル: event_watcher.py プロジェクト: malkush/eventify
def run():
    logger.debug('service started')
    service = Service(config_file='config-debug.json',
                      callback=my_example_event_handler).start()
コード例 #2
0
ファイル: test_drivers.py プロジェクト: sunds/eventify
 def test_load_driver(self):
     service = Service(config_file='test/config-test.json',
                       handlers=self.test_load_driver)
コード例 #3
0
 def test_load_driver(self):
     service = Service(config_file='test/config-test.json', callback=self.test_load_driver)
コード例 #4
0
ファイル: manage_events.py プロジェクト: sunds/eventify
#!/usr/bin/env python
"""
Minimal viable microservice that publishes events
to test how system works
"""
import logging
import sys

from eventify.event import Event
from eventify.service import Service

FORMAT = '%(asctime)-15s %(name)s %(levelname)s %(message)s'
logging.basicConfig(stream=sys.stdout, format=FORMAT, level=logging.DEBUG)
logger = logging.getLogger('event.producer')


async def display_stats(session):
    # show all session data
    await session.show_sessions()

    # show total sessions
    await session.total_sessions()

    # lookup session
    await session.lookup_session('example')


if __name__ == '__main__':
    service = Service(config_file='config-manage.json', callback=display_stats)
    service.start_producer()
コード例 #5
0
ファイル: ex_pub.py プロジェクト: sunds/eventify
def run():
    """
    Run an eventify service
    """
    Service(config_file='config.json', handlers=[Collector]).start()
コード例 #6
0
import time

from eventify.event import Event
from eventify.service import Service


FORMAT = '%(asctime)-15s %(name)s %(levelname)s %(message)s'
logging.basicConfig(stream=sys.stdout, format=FORMAT, level=logging.DEBUG)
logger = logging.getLogger('event.producer')

async def produce_events(session):
    """
    Produces 10 events
    """
    print('called')
    logger.debug('called')
    counter = 1
    for number in range(1,11):
        print(counter)
        event = Event({
            "name": "EventProduced",
            "message": "Event %s" % number
        })
        await session.emit_event(event)
        counter = counter + 1


if __name__ == '__main__':
    service = Service(config_file='config-producer.json', callback=produce_events)
    service.start_producer()