#include "message_bus/ingress/DriverIngressAdapter.h"

#include "message_bus/pipeline/PipelineEngine.h"
#include "utils/logs/logging.h"

namespace softbus::message_bus::ingress
{

DriverIngressAdapter::DriverIngressAdapter(std::shared_ptr<softbus::core::memory::MemoryPool> pool,
                                           softbus::message_bus::pipeline::PipelineEngine* engine)
    : m_pool(std::move(pool)), m_engine(engine)
{
}

bool DriverIngressAdapter::push(softbus::message_bus::pipeline::PipelineContext ctx)
{
    if (!m_engine) {
        return false;
    }
    return m_engine->enqueueIngress(std::move(ctx));
}

void DriverIngressAdapter::reportError(const QString& endpoint, const QString& error)
{
    LOG_WARNING() << "Ingress error endpoint=" << endpoint << "message=" << error;
}

} // namespace softbus::message_bus::ingress
