Refactor event emitter to not use event partials

event emitter now caches to memcache where it is eventually picked up
by the stdout event emitter. This obviates event reassembly in the
callback receiver.
This commit is contained in:
Matthew Jones
2017-01-17 15:59:43 -05:00
parent e594a3ee3e
commit 1cdeb4d2af
5 changed files with 14 additions and 19 deletions

View File

@@ -87,24 +87,10 @@ class CallbackBrokerWorker(ConsumerMixin):
if settings.DEBUG:
logger.info('Body: {}'.format(body))
try:
# If event came directly from callback without counter/stdout,
# save it until the rest of the event arrives.
if 'counter' not in body:
if 'uuid' in body:
self.partial_events[body['uuid']] = body
# If event has counter, try to combine it with any event data
# already received for the same uuid, then create the actual
# job event record.
else:
if 'uuid' in body:
partial_event = self.partial_events.pop(body['uuid'], {})
body.update(partial_event)
else:
continue
if 'job_id' in body:
JobEvent.create_from_data(**body)
elif 'ad_hoc_command_id' in body:
AdHocCommandEvent.create_from_data(**body)
if 'job_id' in body:
JobEvent.create_from_data(**body)
elif 'ad_hoc_command_id' in body:
AdHocCommandEvent.create_from_data(**body)
except DatabaseError as e:
logger.error('Database Error Saving Job Event: {}'.format(e))
except Exception as exc: