Show More
@@ -15,10 +15,11 b' TaskRecords are dicts of the form::' | |||||
15 | 'header' : dict(header), |
|
15 | 'header' : dict(header), | |
16 | 'content': dict(content), |
|
16 | 'content': dict(content), | |
17 | 'buffers': list(buffers), |
|
17 | 'buffers': list(buffers), | |
18 | 'submitted': datetime, |
|
18 | 'submitted': datetime or None, | |
19 | 'started': datetime or None, |
|
19 | 'started': datetime or None, | |
20 | 'completed': datetime or None, |
|
20 | 'completed': datetime or None, | |
21 |
're |
|
21 | 'received': datetime or None, | |
|
22 | 'resubmitted': str(uuid) or None, | |||
22 | 'result_header' : dict(header) or None, |
|
23 | 'result_header' : dict(header) or None, | |
23 | 'result_content' : dict(content) or None, |
|
24 | 'result_content' : dict(content) or None, | |
24 | 'result_buffers' : list(buffers) or None, |
|
25 | 'result_buffers' : list(buffers) or None, | |
@@ -31,16 +32,7 b' e.g.:' | |||||
31 | * client's outstanding: client_uuid = uuid && completed is None |
|
32 | * client's outstanding: client_uuid = uuid && completed is None | |
32 | * MIA: arrived is None (and completed is None) |
|
33 | * MIA: arrived is None (and completed is None) | |
33 |
|
34 | |||
34 | EngineRecords are dicts of the form:: |
|
35 | DictDB supports a subset of mongodb operators:: | |
35 |
|
||||
36 | { |
|
|||
37 | 'eid' : int(id), |
|
|||
38 | 'uuid': str(uuid) |
|
|||
39 | } |
|
|||
40 |
|
||||
41 | This may be extended, but is currently. |
|
|||
42 |
|
||||
43 | We support a subset of mongodb operators:: |
|
|||
44 |
|
36 | |||
45 | $lt,$gt,$lte,$gte,$ne,$in,$nin,$all,$mod,$exists |
|
37 | $lt,$gt,$lte,$gte,$ne,$in,$nin,$all,$mod,$exists | |
46 | """ |
|
38 | """ | |
@@ -210,12 +202,19 b' class DictDB(BaseDB):' | |||||
210 | before_count, before, self.size_limit, culled |
|
202 | before_count, before, self.size_limit, culled | |
211 | ) |
|
203 | ) | |
212 |
|
204 | |||
|
205 | def _check_dates(self, rec): | |||
|
206 | for key in ('submitted', 'started', 'completed'): | |||
|
207 | value = rec.get(key, None) | |||
|
208 | if value is not None and not isinstance(value, datetime): | |||
|
209 | raise ValueError("%s must be None or datetime, not %r" % (key, value)) | |||
|
210 | ||||
213 | # public API methods: |
|
211 | # public API methods: | |
214 |
|
212 | |||
215 | def add_record(self, msg_id, rec): |
|
213 | def add_record(self, msg_id, rec): | |
216 | """Add a new Task Record, by msg_id.""" |
|
214 | """Add a new Task Record, by msg_id.""" | |
217 | if msg_id in self._records: |
|
215 | if msg_id in self._records: | |
218 | raise KeyError("Already have msg_id %r"%(msg_id)) |
|
216 | raise KeyError("Already have msg_id %r"%(msg_id)) | |
|
217 | self._check_dates(rec) | |||
219 | self._records[msg_id] = rec |
|
218 | self._records[msg_id] = rec | |
220 | self._add_bytes(rec) |
|
219 | self._add_bytes(rec) | |
221 | self._maybe_cull() |
|
220 | self._maybe_cull() | |
@@ -232,6 +231,7 b' class DictDB(BaseDB):' | |||||
232 | """Update the data in an existing record.""" |
|
231 | """Update the data in an existing record.""" | |
233 | if msg_id in self._culled_ids: |
|
232 | if msg_id in self._culled_ids: | |
234 | raise KeyError("Record %r has been culled for size" % msg_id) |
|
233 | raise KeyError("Record %r has been culled for size" % msg_id) | |
|
234 | self._check_dates(rec) | |||
235 | _rec = self._records[msg_id] |
|
235 | _rec = self._records[msg_id] | |
236 | self._drop_bytes(_rec) |
|
236 | self._drop_bytes(_rec) | |
237 | _rec.update(rec) |
|
237 | _rec.update(rec) |
General Comments 0
You need to be logged in to leave comments.
Login now