示例#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)
示例#2
0
文件: __init__.py 项目: Livefyre/voom
from collections import namedtuple
from voom.events.base import Event

GatewayShutdownCmd = namedtuple("GatewayShutdownCmd", "")

GatewayMessageDecodeError = Event.new("GatewayMessageDecodeError",
                                      "event exception traceback")
示例#3
0
文件: __init__.py 项目: Livefyre/voom
from collections import namedtuple
from voom.events.base import Event

GatewayShutdownCmd = namedtuple("GatewayShutdownCmd", "")

GatewayMessageDecodeError = Event.new("GatewayMessageDecodeError", "event exception traceback")
示例#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):
示例#5
0
文件: events.py 项目: Livefyre/voom
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")
示例#6
0
文件: events.py 项目: Livefyre/voom
from voom.events.base import Event

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

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

__ALL__ = ['Event']

MessageForwarded = Event.new("MessageForwarded", "address message")
示例#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")