コード例 #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)
コード例 #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))
コード例 #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))
コード例 #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
コード例 #5
0
ファイル: common.py プロジェクト: exarkun/foolscap
 def hang():
     return Any()
コード例 #6
0
ファイル: common.py プロジェクト: exarkun/foolscap
 def defer(obj=Any()):
     return Any()
コード例 #7
0
ファイル: common.py プロジェクト: exarkun/foolscap
 def echo(obj=Any()):
     return Any()
コード例 #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"
コード例 #9
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def get(): return Any()
 def echo(obj=Any()): return Any()
コード例 #10
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def set2(obj1=Any(), obj2=Any()): return bool
 def append(obj=Any()): return Any()
コード例 #11
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def hang(): return Any()
 # test one of everything
 def megaschema(obj1=MegaSchema1, obj2=MegaSchema2): return None
コード例 #12
0
ファイル: interfaces.py プロジェクト: byrgazov/foolscap
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"
コード例 #13
0
 def get_versions():
     return DictOf(Any(), Any())
コード例 #14
0
 def new_incident(name=Any(), trigger=Event):
     # should this give (tubid, incarnation, trigger) like list_incidents?
     return None
コード例 #15
0
ファイル: common.py プロジェクト: byrgazov/foolscap
    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
コード例 #16
0
ファイル: interfaces.py プロジェクト: byrgazov/foolscap
 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
コード例 #17
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def defer(obj=Any()): return Any()
 def hang(): return Any()
コード例 #18
0
ファイル: common.py プロジェクト: exarkun/foolscap
 def set(obj=Any()):
     return bool
コード例 #19
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def set(obj=Any()): return bool
 def set2(obj1=Any(), obj2=Any()): return bool
コード例 #20
0
ファイル: common.py プロジェクト: exarkun/foolscap
 def append(obj=Any()):
     return Any()
コード例 #21
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def append(obj=Any()): return Any()
 def get(): return Any()
コード例 #22
0
ファイル: common.py プロジェクト: exarkun/foolscap
 def get():
     return Any()
コード例 #23
0
ファイル: common.py プロジェクト: byrgazov/foolscap
 def echo(obj=Any()): return Any()
 def defer(obj=Any()): return Any()
コード例 #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))