agentultra/dmon — pull request #2 by smoynes (2013-05-16 20:05:30+00:00)
Title: Add event index

The index stores events in memory and uses `(host, service)` as a uniqueness key.

The Index supports several operations:

- `update(event)`: adds an event to the index
- `get(host, service)`: retrieves an event
- `delete(event)`: removes an event
- `expire(expiry_time)`: removes and returns all events with `time + ttl <= expiry_time`
- `clear()`: empties the index

The index is composed of two data structures:
- `store`: a dict mapping `(host, service)` to an event
- `deadlines`: a dict mapping a time to a list of event keys