def schedule(self, channel, eta, event_type, payload): self.redis.zadd(self.schedule_key, eta, msgpack.dumps({ 'id': make_id(), 'event_type': event_type, 'payload': payload, })) channel.ack()
def __init__(self, msg_type, subject, packed_body=None, headers=None, packed_headers=None, msg_id=None, source=None, lazy=False, **kwargs): self.id = msg_id if msg_id else make_id() self.type = msg_type self.subject = subject self.source = source if headers and packed_headers: raise TypeError("Message takes either 'headers' or 'packed_headers' not both") elif not headers and not packed_headers: headers = {} self._headers = headers self._packed_headers = packed_headers if 'body' in kwargs: if packed_body is not None: raise TypeError("Message takes either 'body' or 'packed_body' not both") self._body = kwargs['body'] elif packed_body is None: raise TypeError("Message requires either 'body' or 'packed_body'") self._packed_body = packed_body if not lazy: self.body self.packed_body self.headers self.packed_headers
def schedule(self, eta, event_type, payload): self.redis.zadd( self.schedule_key, eta, msgpack.dumps({ 'id': make_id(), 'event_type': event_type, 'payload': payload, }))