示例#1
0
 def add_event(self, event: BaseEvent):
     kwargs = {
         "server_id": self.server_id,
         "create_time": time.time_ns(),
         "event_type": event.event_type,
         "key": event.key,
         "value": event.value,
     }
     mongo_event = MongoEvent(**kwargs)
     mongo_event.save()
     mongo_event.reload()
     event.create_time = mongo_event.create_time
     event.version = mongo_event.version
     event.id = mongo_event.auto_increase_id
     return event
示例#2
0
 def add_event(self, event: BaseEvent, uuid: str):
     kwargs = {
         "server_id": self.server_id,
         "create_time": int(time.time() * 1000),
         "event_type": event.event_type,
         "key": event.key,
         "value": event.value,
         "context": event.context,
         "namespace": event.namespace,
         "uuid": uuid
     }
     mongo_event = MongoEvent(**kwargs)
     mongo_event.save()
     mongo_event.reload()
     event.create_time = mongo_event.create_time
     event.version = mongo_event.version
     return event