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