1
# Copyright 2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Long-poll infrastructure interfaces."""
13
from zope.interface import (
19
class ILongPollEvent(Interface):
21
source = Attribute("The event source.")
23
event = Attribute("An object indicating the type of event.")
25
event_key = Attribute(
26
"The key with which events will be emitted. Should be predictable "
30
"""Emit the given data to `event_key`.
32
The data will be wrapped up into a `dict` with the keys `event_key`
33
and `event_data`, where `event_key` is a copy of `self.event_key` and
34
`event_data` is the `data` argument.
36
:param data: Any data structure that can be dumped as JSON.
40
class ILongPollSubscriber(Interface):
42
subscribe_key = Attribute(
43
"The key which the subscriber must know in order to be able "
44
"to long-poll for subscribed events. Should be infeasible to "
45
"guess, a UUID for example.")
48
"""Subscribe to the given event.
50
:type event: ILongPollEvent