def publish!(topic, subtopic, schema, partition_key, payload)
      event = Event.new(topic, subtopic, origin, schema, partition_key, payload)
      raise MegaphoneInvalidEventError.new(event.errors.join(', ')) unless event.valid?
      unless logger.post(topic, event.to_hash)
        if transient_error?(logger.last_error)
          raise MegaphoneMessageDelayWarning.new(logger.last_error.message, event.stream_id)
        else
          raise MegaphoneUnavailableError.new(logger.last_error.message, event.stream_id)
        end
      end
    end
def publish!(topic, subtopic, schema, partition_key, payload)
      event = Event.new(topic, subtopic, origin, schema, partition_key, payload)
      raise MegaphoneInvalidEventError.new(event.errors.join(', ')) unless event.valid?
      unless logger.post(topic, event.to_hash)
        if transient_error?(logger.last_error)
          raise MegaphoneMessageDelayWarning.new(logger.last_error.message, event.stream_id)
        else
          raise MegaphoneUnavailableError.new(logger.last_error.message, event.stream_id)
        end
      end
    end
Main entry point for apps using this library.
 Will default to environment for host and port settings, if not passed.
 Note that a missing callback_handler will result in a default handler
 being assigned if the FluentLogger is used.