Beispiel #1
0
    def list_incidents(since=Optional(Any(), "")):
        """Return a dict that maps an 'incident name' (a string of the form
        'incident-TIMESTAMP-UNIQUE') to the triggering event (a single event
        dictionary). The incident name can be passed to get_incident() to
        obtain the list of events (including header) contained inside the
        incident report. Incident names will sort in chronological order.

        If the optional since= argument is provided, then this will only
        return incident names that are alphabetically greater (and thus
        chronologically later) than the given string. This can be used to
        poll an application for incidents that have occurred since a previous
        query. For real-time reporting, use subscribe_to_incidents() instead.
        """
        return DictOf(Any(), Event)
Beispiel #2
0
 def get_header():
     # (tubid, incarnation,
     #  (first_event: number, time), (last_event: number, time),
     #  num_events,
     #  level_map, # maps string severity to count of messages
     # )
     return (TubID, int, (int, int), (int, int), int, DictOf(Any(), int))
Beispiel #3
0
 def get_incident(incident_name=Any()):
     """Given an incident name, return the header dict and list of event
     dicts for that incident."""
     # note that this puts all the events in memory at the same time, but
     # we expect the logfiles to be of a reasonable size: not much larger
     # than the circular buffers that we keep around anyways.
     return (Header, ListOf(Event))
Beispiel #4
0
    def subscribe_to_incidents(observer=RILogObserver,
                               catch_up=Optional(bool, False),
                               since=Optional(Any(), "")):
        """Subscribe to hear about new Incidents, optionally catching up on
        old ones.

        Each new Incident will be reported by name+trigger to the observer by
        a new_incident() message. This message will be sent after the
        incident reporter has finished working (usually a few seconds after
        the triggering event).

        If catch_up=True, then old Incidents will be sent to the observer
        before any new ones are reported. When the publisher has finished
        sending the names of all old events, it will send a
        done_with_incident_catchup() message to the observer. Only old
        Incidents with a name that is alphabetically greater (and thus later)
        than the since= argument will be sent. Use since='' to catch up on
        all old Incidents.

        Call unsubscribe() on the returned RISubscription object to stop
        receiving messages.
        """
        return RISubscription
Beispiel #5
0
 def hang():
     return Any()
Beispiel #6
0
 def defer(obj=Any()):
     return Any()
Beispiel #7
0
 def echo(obj=Any()):
     return Any()
Beispiel #8
0
from zope.interface import Interface
from foolscap.remoteinterface import RemoteInterface
from foolscap.schema import DictOf, ListOf, Any, Optional, ChoiceOf

TubID = Any()  # printable, base32 encoded
Incarnation = (Any(), ChoiceOf(Any(), None))
Header = DictOf(Any(), Any())
Event = DictOf(Any(), Any())  # this has message:, level:, facility:, etc
EventWrapper = DictOf(Any(), Any())  # this has from:, rx_time:, and d:


class RILogObserver(RemoteInterface):
    __remote_name__ = "RILogObserver.foolscap.lothar.com"

    def msg(logmsg=Event):
        return None

    def done():
        return None

    def new_incident(name=Any(), trigger=Event):
        # should this give (tubid, incarnation, trigger) like list_incidents?
        return None

    def done_with_incident_catchup():
        return None


class RILogFile(RemoteInterface):
    __remote_name__ = "RILogFile.foolscap.lothar.com"
Beispiel #9
0
 def get(): return Any()
 def echo(obj=Any()): return Any()
Beispiel #10
0
 def set2(obj1=Any(), obj2=Any()): return bool
 def append(obj=Any()): return Any()
Beispiel #11
0
 def hang(): return Any()
 # test one of everything
 def megaschema(obj1=MegaSchema1, obj2=MegaSchema2): return None
Beispiel #12
0
from zope.interface import Interface
from foolscap.remoteinterface import RemoteInterface
from foolscap.schema import DictOf, ListOf, Any, Optional, ChoiceOf

TubID = str  # printable, base32 encoded
Incarnation = (str, ChoiceOf(str, None))
Header = DictOf(str, Any())
Event = DictOf(str, Any())  # this has message:, level:, facility:, etc
EventWrapper = DictOf(str, Any())  # this has from:, rx_time:, and d:


class RILogObserver(RemoteInterface):
    __remote_name__ = "RILogObserver.foolscap.lothar.com"

    def msg(logmsg=Event):
        pass

    def done():
        pass

    def new_incident(name=str, trigger=Event):
        # should this give (tubid, incarnation, trigger) like list_incidents?
        pass

    def done_with_incident_catchup():
        pass


class RILogFile(RemoteInterface):
    __remote_name__ = "RILogFile.foolscap.lothar.com"
Beispiel #13
0
 def get_versions():
     return DictOf(Any(), Any())
Beispiel #14
0
 def new_incident(name=Any(), trigger=Event):
     # should this give (tubid, incarnation, trigger) like list_incidents?
     return None
Beispiel #15
0
    def flush(self):
        self.connected = False
        return fireEventually()

    def getPeer(self):
        return broker.LoopbackAddress()
    def getHost(self):
        return broker.LoopbackAddress()

Digits = re.compile('\d*')

MegaSchema1 = DictOf(str, ListOf(TupleOf(SetOf(int, maxLength=10, mutable=True),
        bytes, bool, int, float, None,
        StringConstraint(),
        ByteStringConstraint(),
        Any(),
        NumberConstraint(),
        IntegerConstraint(),
        StringConstraint(maxLength=100, minLength=90, regexp='\w+'),
        StringConstraint(regexp=Digits),
    ),
    maxLength=20),
    maxKeys=5)

# containers should convert their arguments into schemas
MegaSchema2 = TupleOf(SetOf(int), ListOf(int), DictOf(int, str))
MegaSchema3 = ListOf(TupleOf(int, int))


class RIHelper(RemoteInterface):
    def set(obj=Any()): return bool
Beispiel #16
0
 def unsubscribe(subscription=Any()):
     # NOTE: this is deprecated. Use subscription.unsubscribe() instead.
     # I don't know how to get the constraint right: unsubscribe() should
     # accept return value of subscribe_to_all()
     return None
Beispiel #17
0
 def defer(obj=Any()): return Any()
 def hang(): return Any()
Beispiel #18
0
 def set(obj=Any()):
     return bool
Beispiel #19
0
 def set(obj=Any()): return bool
 def set2(obj1=Any(), obj2=Any()): return bool
Beispiel #20
0
 def append(obj=Any()):
     return Any()
Beispiel #21
0
 def append(obj=Any()): return Any()
 def get(): return Any()
Beispiel #22
0
 def get():
     return Any()
Beispiel #23
0
 def echo(obj=Any()): return Any()
 def defer(obj=Any()): return Any()
Beispiel #24
0
    def flush(self):
        self.connected = False
        return fireEventually()

    def getPeer(self):
        return broker.LoopbackAddress()
    def getHost(self):
        return broker.LoopbackAddress()

Digits = re.compile("\d*")
MegaSchema1 = DictOf(str,
                     ListOf(TupleOf(SetOf(int, maxLength=10, mutable=True),
                                    str, bool, int, long, float, None,
                                    UnicodeConstraint(),
                                    ByteStringConstraint(),
                                    Any(), NumberConstraint(),
                                    IntegerConstraint(),
                                    ByteStringConstraint(maxLength=100,
                                                         minLength=90,
                                                         regexp="\w+"),
                                    ByteStringConstraint(regexp=Digits),
                                    ),
                            maxLength=20),
                     maxKeys=5)
# containers should convert their arguments into schemas
MegaSchema2 = TupleOf(SetOf(int),
                      ListOf(int),
                      DictOf(int, str),
                      )
MegaSchema3 = ListOf(TupleOf(int,int))