Beispiel #1
0
    def test_1(self):
        klass = Event.new("EV", "a b c")

        i = klass(1, 2, 3)
        print repr(i)

        assert i == i
        assert i != 1
        assert i == klass(1, 2, 3)
        assert i != klass(1, 2, 4)
Beispiel #2
0
from collections import namedtuple
from voom.events.base import Event

GatewayShutdownCmd = namedtuple("GatewayShutdownCmd", "")

GatewayMessageDecodeError = Event.new("GatewayMessageDecodeError",
                                      "event exception traceback")
Beispiel #3
0
from collections import namedtuple
from voom.events.base import Event

GatewayShutdownCmd = namedtuple("GatewayShutdownCmd", "")

GatewayMessageDecodeError = Event.new("GatewayMessageDecodeError", "event exception traceback")
Beispiel #4
0
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) # make this file executable

### BEGIN
from voom.bus import VoomBus
from voom.events.base import Event
from voom.decorators import receiver
from collections import defaultdict
import time

# our fake data stores
user_stats_db = defaultdict(lambda: defaultdict(int))
stats_db = defaultdict(int)
activity_db = defaultdict(list)

# our simplistic events
UserDidSomething = Event.new("UserDidSomething", "user thing when")
UserDidSomethingElse = Event.new("UserDidSomethingElse", "user thing when")

#
# our naive event handlers
#
@receiver(UserDidSomething)
def incrementUserActivity(event):
    user_stats_db[event.user][event.thing] += 1

@receiver(UserDidSomething)
def incrementGlobalActivity(event):
    stats_db[event.thing] += 1
    
@receiver(UserDidSomething, UserDidSomethingElse)
def appendToStream(event):
Beispiel #5
0
from voom.events.base import Event

AMQPQueueBound = Event.new("AMQPQueueBound", "binding")

AMQPConnectionReady = Event.new("AMQPConnectionReady", "connection")

AMQPChannelReady = Event.new("AMQPChannelReady", "channel connection")

AMQPQueueInitialized = Event.new("AMQPQueueInitialized", "descriptor")

AMQPExchangeInitialized = Event.new("AMQPExchangeInitialized", "descriptor")

AMQPConsumerStarted = Event.new("AMQPConsumerStarted", "descriptor consumer_tag")

AMQPRawDataReceived = Event.new("AMQPRawDataReceived", "channel method properties body")

AMQPDataReceived = Event.new("AMQPDataReceived", "messages headers decoded_body receive_event")

AMQPGatewayReady = Event.new("AMQPGatewayReady", "gateway")

AMQPSenderReady = Event.new("AMQPSenderReady", "sender")
Beispiel #6
0
from voom.events.base import Event

IMAPMessageDownloaded = Event.new("IMAPMessageDownloaded", "num mime_message connection")
Beispiel #7
0
from voom.events.base import Event

IMAPMessageDownloaded = Event.new("IMAPMessageDownloaded",
                                  "num mime_message connection")
Beispiel #8
0
from voom.events.base import Event

__ALL__ = ['Event']

MessageForwarded = Event.new("MessageForwarded", "address message")
Beispiel #9
0
from voom.events.base import Event

AMQPQueueBound = Event.new("AMQPQueueBound", "binding")

AMQPConnectionReady = Event.new("AMQPConnectionReady", "connection")

AMQPChannelReady = Event.new("AMQPChannelReady", "channel connection")

AMQPQueueInitialized = Event.new("AMQPQueueInitialized", "descriptor")

AMQPExchangeInitialized = Event.new("AMQPExchangeInitialized", "descriptor")

AMQPConsumerStarted = Event.new("AMQPConsumerStarted",
                                "descriptor consumer_tag")

AMQPRawDataReceived = Event.new("AMQPRawDataReceived",
                                "channel method properties body")

AMQPDataReceived = Event.new("AMQPDataReceived",
                             "messages headers decoded_body receive_event")

AMQPGatewayReady = Event.new("AMQPGatewayReady", "gateway")

AMQPSenderReady = Event.new("AMQPSenderReady", "sender")