1
2 """PgQ event container.
3 """
4
5 __all__ = ('EV_RETRY', 'EV_DONE', 'EV_FAILED', 'Event')
6
7
8 EV_RETRY = 0
9 EV_DONE = 1
10 EV_FAILED = 2
11
12 _fldmap = {
13 'ev_id': 'ev_id',
14 'ev_txid': 'ev_txid',
15 'ev_time': 'ev_time',
16 'ev_type': 'ev_type',
17 'ev_data': 'ev_data',
18 'ev_extra1': 'ev_extra1',
19 'ev_extra2': 'ev_extra2',
20 'ev_extra3': 'ev_extra3',
21 'ev_extra4': 'ev_extra4',
22
23 'id': 'ev_id',
24 'txid': 'ev_txid',
25 'time': 'ev_time',
26 'type': 'ev_type',
27 'data': 'ev_data',
28 'extra1': 'ev_extra1',
29 'extra2': 'ev_extra2',
30 'extra3': 'ev_extra3',
31 'extra4': 'ev_extra4',
32 }
33
35 """Event data for consumers.
36
37 Consumer is supposed to tag them after processing.
38 If not, events will stay in retry queue.
39 """
41 self._event_row = row
42 self.status = EV_RETRY
43 self.retry_time = 60
44 self.fail_reason = "Buggy consumer"
45 self.queue_name = queue_name
46
48 return self._event_row[_fldmap[key]]
49
52
56
60