示例#1
0
    def process(self, event: Event):
        # TODO - This shouldn't be set here
        event.garden = conf.get("garden.name")

        if not event_blocklisted(event):
            try:
                operation = Operation(
                    operation_type="PUBLISH_EVENT", model=event, model_type="Event"
                )
                self._ez_client.forward(operation)
            except RequestException as ex:
                self.logger.error(f"Error while publishing event to parent: {ex}")

                self._connected = False
                self._reconnect()
示例#2
0
def publish(event: Event) -> None:
    """Convenience method for publishing events

    All this does is place the event on the queue for the process-wide manager to pick
    up and process.

    Args:
        event: The event to publish

    Returns:
        None
    """
    try:
        # Do some formatting / tweaking
        if not event.garden:
            event.garden = config.get("garden.name")
        if not event.timestamp:
            event.timestamp = datetime.now(timezone.utc)

        return manager.put(event)
    except Exception as ex:
        logger.exception(f"Error publishing event: {ex}")