rawbusmessage
This commit is contained in:
@@ -17,7 +17,7 @@ void EgressRouter::unbindSerialDevice(const QString& endpoint)
|
||||
m_serialByEndpoint.remove(endpoint);
|
||||
}
|
||||
|
||||
bool EgressRouter::send(const softbus::message_bus::pipeline::PipelineContext& ctx)
|
||||
bool EgressRouter::send(const softbus::core::models::RawBusMessage& ctx)
|
||||
{
|
||||
auto it = m_serialByEndpoint.constFind(ctx.endpoint);
|
||||
if (it == m_serialByEndpoint.constEnd() || !it.value() || !ctx.payload.valid()) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void bindSerialDevice(const QString& endpoint,
|
||||
const QSharedPointer<softbus::devices::physical::SerialDevice>& device);
|
||||
void unbindSerialDevice(const QString& endpoint);
|
||||
bool send(const softbus::message_bus::pipeline::PipelineContext& ctx) override;
|
||||
bool send(const softbus::core::models::RawBusMessage& ctx) override;
|
||||
|
||||
private:
|
||||
QHash<QString, QSharedPointer<softbus::devices::physical::SerialDevice>> m_serialByEndpoint;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "message_bus/pipeline/PipelineContext.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::egress
|
||||
{
|
||||
@@ -9,7 +9,7 @@ class IEgressPort
|
||||
{
|
||||
public:
|
||||
virtual ~IEgressPort() = default;
|
||||
virtual bool send(const softbus::message_bus::pipeline::PipelineContext& ctx) = 0;
|
||||
virtual bool send(const softbus::core::models::RawBusMessage& ctx) = 0;
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::egress
|
||||
|
||||
@@ -17,9 +17,7 @@ bool DriverIngressAdapter::push(softbus::core::models::RawBusMessage ctx)
|
||||
if (!m_engine) {
|
||||
return false;
|
||||
}
|
||||
softbus::message_bus::pipeline::PipelineContext pipelineCtx;
|
||||
pipelineCtx.raw() = std::move(ctx);
|
||||
return m_engine->enqueueIngress(std::move(pipelineCtx));
|
||||
return m_engine->enqueueIngress(std::move(ctx));
|
||||
}
|
||||
|
||||
void DriverIngressAdapter::reportError(const QString& endpoint, const QString& error)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
// 功能 :定义有效载荷引用 包含数据块、偏移量、长度
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
#include "core/memory/MemoryPool.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline
|
||||
{
|
||||
|
||||
struct PayloadRef
|
||||
{
|
||||
softbus::core::memory::MemoryPool::BlockPtr block;
|
||||
std::size_t offset{0};
|
||||
std::size_t length{0};
|
||||
|
||||
const std::uint8_t* bytes() const
|
||||
{
|
||||
if (!block || !block->data || offset > block->capacity) {
|
||||
return nullptr;
|
||||
}
|
||||
return block->data + offset;
|
||||
}
|
||||
|
||||
bool valid() const
|
||||
{
|
||||
return block && block->data && (offset + length <= block->capacity);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline
|
||||
|
||||
Q_DECLARE_METATYPE(softbus::message_bus::pipeline::PayloadRef)
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <QMetaType>
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline
|
||||
{
|
||||
|
||||
enum class FrameKind
|
||||
{
|
||||
StreamChunk,
|
||||
CompleteFrame,
|
||||
};
|
||||
|
||||
using BusDirection = softbus::core::models::BusDirection;
|
||||
|
||||
struct PipelineContext : public softbus::core::models::RawBusMessage
|
||||
{
|
||||
FrameKind frameKind{FrameKind::StreamChunk};
|
||||
std::uint64_t frameSeq{0};
|
||||
softbus::core::models::RawBusMessage& raw() { return *this; }
|
||||
const softbus::core::models::RawBusMessage& raw() const { return *this; }
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline
|
||||
|
||||
Q_DECLARE_METATYPE(softbus::message_bus::pipeline::PipelineContext)
|
||||
@@ -13,14 +13,14 @@ namespace softbus::message_bus::pipeline
|
||||
|
||||
struct EndpointFramingState
|
||||
{
|
||||
softbus::core::memory::LockFreeQueue<PipelineContext> chunkQ;
|
||||
softbus::core::memory::LockFreeQueue<softbus::core::models::RawBusMessage> chunkQ;
|
||||
std::atomic<bool> running{true};
|
||||
std::thread th;
|
||||
std::uint64_t nextSeq{1};
|
||||
QString endpoint;
|
||||
std::shared_ptr<softbus::core::memory::MemoryPool> pool;
|
||||
std::function<void(PipelineContext&, std::vector<PipelineContext>&)> feed;
|
||||
std::function<void(PipelineContext)> pushFramed;
|
||||
std::function<void(softbus::core::models::RawBusMessage&, std::vector<softbus::core::models::RawBusMessage>&)> feed;
|
||||
std::function<void(QString, std::uint64_t, softbus::core::models::RawBusMessage)> pushFramed;
|
||||
|
||||
explicit EndpointFramingState(std::size_t cap)
|
||||
: chunkQ(cap)
|
||||
@@ -34,19 +34,19 @@ namespace
|
||||
void endpointFramerThread(std::shared_ptr<EndpointFramingState> st)
|
||||
{
|
||||
while (st->running.load(std::memory_order_acquire)) {
|
||||
PipelineContext ch;
|
||||
softbus::core::models::RawBusMessage ch;
|
||||
if (!st->chunkQ.pop(ch)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
continue;
|
||||
}
|
||||
std::vector<PipelineContext> out;
|
||||
std::vector<softbus::core::models::RawBusMessage> out;
|
||||
if (st->feed) {
|
||||
st->feed(ch, out);
|
||||
}
|
||||
for (auto& x : out) {
|
||||
x.frameSeq = st->nextSeq++;
|
||||
const std::uint64_t seq = st->nextSeq++;
|
||||
if (st->pushFramed) {
|
||||
st->pushFramed(std::move(x));
|
||||
st->pushFramed(st->endpoint, seq, std::move(x));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void PipelineEngine::start()
|
||||
// 合并队列是用来存储合并的帧的
|
||||
// 合并线程是用来处理合并的帧的
|
||||
if (m_rtConfig.parallelPipeline) {
|
||||
m_framedQ = std::make_unique<softbus::core::threading::MutexQueue<PipelineContext>>(m_rtConfig.framedQueueMax);
|
||||
m_framedQ = std::make_unique<softbus::core::threading::MutexQueue<MergeItem>>(m_rtConfig.framedQueueMax);
|
||||
for (int i = 0; i < m_rtConfig.parseWorkerCount; ++i) {
|
||||
// 创建解析线程 解析线程从帧队列中取出帧 进行处理
|
||||
// emplace_back 是用来创建解析线程的 参数是 lambda 表达式
|
||||
@@ -187,7 +187,7 @@ void PipelineEngine::stop()
|
||||
// 逻辑 :从 ingress 队列中取出数据 直到队列为空
|
||||
void PipelineEngine::drain()
|
||||
{
|
||||
PipelineContext tmp;
|
||||
softbus::core::models::RawBusMessage tmp;
|
||||
while (m_ingressQ.pop(tmp)) {
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void PipelineEngine::drain()
|
||||
// 参数 :ctx 数据
|
||||
// 返回值 :是否成功
|
||||
// 逻辑 :如果并行管道启用 则根据端点确保帧解析器 然后推送到帧队列 如果并行管道未启用 则直接推送到 ingress 队列
|
||||
bool PipelineEngine::enqueueIngress(PipelineContext ctx)
|
||||
bool PipelineEngine::enqueueIngress(softbus::core::models::RawBusMessage ctx)
|
||||
{
|
||||
if (m_rtConfig.parallelPipeline) {
|
||||
if (ctx.endpoint.isEmpty()) {
|
||||
@@ -227,7 +227,7 @@ bool PipelineEngine::enqueueIngress(PipelineContext ctx)
|
||||
// 参数 :ctx 数据
|
||||
// 返回值 :是否成功
|
||||
// 逻辑 :将数据推送到 egress 队列
|
||||
bool PipelineEngine::enqueueEgress(PipelineContext ctx)
|
||||
bool PipelineEngine::enqueueEgress(softbus::core::models::RawBusMessage ctx)
|
||||
{
|
||||
return m_egressQ.push(std::move(ctx));
|
||||
}
|
||||
@@ -235,7 +235,7 @@ bool PipelineEngine::enqueueEgress(PipelineContext ctx)
|
||||
// 参数 :out 数据
|
||||
// 返回值 :是否成功
|
||||
// 逻辑 :从 egress 队列中取出数据 如果队列为空 则返回false 如果队列不为空 则返回true
|
||||
bool PipelineEngine::tryPopEgress(PipelineContext& out)
|
||||
bool PipelineEngine::tryPopEgress(softbus::core::models::RawBusMessage& out)
|
||||
{
|
||||
return m_egressQ.pop(out);
|
||||
}
|
||||
@@ -262,14 +262,19 @@ void PipelineEngine::ensureEndpointFramer(const QString& endpoint)
|
||||
auto st = std::make_shared<EndpointFramingState>(qcap > 0 ? qcap : 4096);
|
||||
st->endpoint = endpoint;
|
||||
st->pool = m_pool;
|
||||
st->feed = [this](PipelineContext& in, std::vector<PipelineContext>& out) {
|
||||
st->feed = [this](softbus::core::models::RawBusMessage& in, std::vector<softbus::core::models::RawBusMessage>& out) {
|
||||
this->dispatchFramer(in, out);
|
||||
};
|
||||
st->pushFramed = [this](PipelineContext c) {
|
||||
st->pushFramed = [this](QString endpoint, std::uint64_t seq, softbus::core::models::RawBusMessage c) {
|
||||
if (!m_framedQ) {
|
||||
return;
|
||||
}
|
||||
if (!m_framedQ->tryPush(std::move(c))) {
|
||||
MergeItem item;
|
||||
item.endpoint = std::move(endpoint);
|
||||
item.seq = seq;
|
||||
item.ctx = std::move(c);
|
||||
item.pipelineOk = true;
|
||||
if (!m_framedQ->tryPush(std::move(item))) {
|
||||
++m_counters.drop;
|
||||
LOG_WARNING() << "PipelineEngine: framed queue full drop";
|
||||
}
|
||||
@@ -281,7 +286,8 @@ void PipelineEngine::ensureEndpointFramer(const QString& endpoint)
|
||||
// 参数 :chunkIn 数据
|
||||
// 返回值 :无
|
||||
// 逻辑 :根据协议提示 选择合适的帧解析器 进行帧解析
|
||||
void PipelineEngine::dispatchFramer(PipelineContext& chunkIn, std::vector<PipelineContext>& completeFramesOut)
|
||||
void PipelineEngine::dispatchFramer(
|
||||
softbus::core::models::RawBusMessage& chunkIn, std::vector<softbus::core::models::RawBusMessage>& completeFramesOut)
|
||||
{
|
||||
if (m_pluginManager) {
|
||||
auto plugin = m_pluginManager->selectProtocolFramerPlugin(chunkIn.protocolHint);
|
||||
@@ -307,29 +313,26 @@ void PipelineEngine::dispatchFramer(PipelineContext& chunkIn, std::vector<Pipeli
|
||||
}
|
||||
}
|
||||
// 功能 :分配帧序列号
|
||||
void PipelineEngine::assignFrameSequence(PipelineContext& ctx)
|
||||
std::uint64_t PipelineEngine::assignFrameSequence(const QString& endpoint)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_seqMutex);
|
||||
ctx.frameSeq = ++m_nextFrameSeqByEndpoint[ctx.endpoint];
|
||||
return ++m_nextFrameSeqByEndpoint[endpoint];
|
||||
}
|
||||
|
||||
void PipelineEngine::runSingleWorker()
|
||||
{
|
||||
// 单线程工作线程 从 ingress 队列中取出数据 进行处理 然后推送到 egress 队列中
|
||||
while (m_running.load(std::memory_order_acquire)) {
|
||||
PipelineContext ctx;
|
||||
softbus::core::models::RawBusMessage ctx;
|
||||
if (!m_ingressQ.pop(ctx)) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<PipelineContext> batch;
|
||||
std::vector<softbus::core::models::RawBusMessage> batch;
|
||||
dispatchFramer(ctx, batch);
|
||||
|
||||
for (auto& c : batch) {
|
||||
if (c.frameKind != FrameKind::CompleteFrame) {
|
||||
continue;
|
||||
}
|
||||
//
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << std::setfill('0');
|
||||
@@ -342,8 +345,8 @@ void PipelineEngine::runSingleWorker()
|
||||
const QString hexPreview = QString::fromStdString(oss.str());
|
||||
LOG_INFO() << "the data is"<< hexPreview;
|
||||
// 分配帧序列号
|
||||
assignFrameSequence(c);
|
||||
if (!runStages234(c)) {
|
||||
const bool ok = runStages234(c);
|
||||
if (!ok) {
|
||||
++m_counters.error;
|
||||
continue;
|
||||
}
|
||||
@@ -359,9 +362,8 @@ void PipelineEngine::runSingleWorker()
|
||||
void PipelineEngine::parseWorkerLoop()
|
||||
{
|
||||
while (true) {
|
||||
PipelineContext ctx;
|
||||
|
||||
const bool have = m_framedQ && m_framedQ->popWaitFor(ctx, m_running, std::chrono::milliseconds(50)); // 从帧队列中取出帧 , 如果帧队列为空 则等待50毫秒
|
||||
MergeItem item;
|
||||
const bool have = m_framedQ && m_framedQ->popWaitFor(item, m_running, std::chrono::milliseconds(50));
|
||||
if (!have) {
|
||||
if (!m_running.load(std::memory_order_acquire)) {
|
||||
break;
|
||||
@@ -369,21 +371,16 @@ void PipelineEngine::parseWorkerLoop()
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const bool ok = runStages234(ctx);
|
||||
const bool ok = runStages234(item.ctx);
|
||||
if (m_rtConfig.orderedEgress && m_mergeQ) {
|
||||
MergeItem it;
|
||||
it.endpoint = ctx.endpoint;
|
||||
it.seq = ctx.frameSeq;
|
||||
it.pipelineOk = ok;
|
||||
it.ctx = std::move(ctx);
|
||||
m_mergeQ->push(std::move(it));
|
||||
item.pipelineOk = ok;
|
||||
m_mergeQ->push(std::move(item));
|
||||
} else {
|
||||
if (!ok) {
|
||||
++m_counters.error;
|
||||
continue;
|
||||
}
|
||||
if (!m_egressQ.push(std::move(ctx))) {
|
||||
if (!m_egressQ.push(std::move(item.ctx))) {
|
||||
++m_counters.drop;
|
||||
continue;
|
||||
}
|
||||
@@ -426,7 +423,7 @@ void PipelineEngine::ingestMergeItem(MergeItem item)
|
||||
auto pr = st.buffer.take(st.nextExpected);
|
||||
++st.nextExpected;
|
||||
const bool pipelineOk = pr.second;
|
||||
PipelineContext ctx = std::move(pr.first);
|
||||
softbus::core::models::RawBusMessage ctx = std::move(pr.first);
|
||||
if (!pipelineOk) {
|
||||
++m_counters.error;
|
||||
continue;
|
||||
@@ -443,11 +440,8 @@ void PipelineEngine::ingestMergeItem(MergeItem item)
|
||||
// 参数 :ctx 数据
|
||||
// 返回值 :是否成功
|
||||
// 逻辑 :如果帧类型不是完整帧 则返回false 如果阶段2解析失败 则返回false 如果阶段3过滤失败 则返回false 如果阶段4验证失败 则返回false 如果都成功 则返回true
|
||||
bool PipelineEngine::runStages234(PipelineContext& ctx)
|
||||
bool PipelineEngine::runStages234(const softbus::core::models::RawBusMessage& ctx)
|
||||
{
|
||||
if (ctx.frameKind != FrameKind::CompleteFrame) {
|
||||
return false;
|
||||
}
|
||||
auto messages = stage2Parser(ctx);
|
||||
LOG_INFO() << "PipelineEngine: stage2Parser messages size=" << messages.size();
|
||||
if (messages.empty()) {
|
||||
@@ -478,7 +472,7 @@ bool PipelineEngine::stage4Validator(const softbus::core::models::DOMMessage& me
|
||||
// 参数 :ctx 数据
|
||||
// 返回值 :是否成功
|
||||
// 逻辑 :如果插件管理器为空 则返回true 如果插件管理器不为空 则选择合适的插件 创建会话 如果会话为空 则返回false 如果会话不为空 则返回true
|
||||
std::vector<softbus::core::models::DOMMessage> PipelineEngine::stage2Parser(const PipelineContext& ctx)
|
||||
std::vector<softbus::core::models::DOMMessage> PipelineEngine::stage2Parser(const softbus::core::models::RawBusMessage& ctx)
|
||||
{
|
||||
if (!m_pluginManager) {
|
||||
return {};
|
||||
@@ -505,7 +499,7 @@ std::vector<softbus::core::models::DOMMessage> PipelineEngine::stage2Parser(cons
|
||||
parserSession = it.value();
|
||||
}
|
||||
softbus::message_bus::pipeline::protocol::ProtocolEnvelope envelope; // 协议封装
|
||||
if (!parserSession->parse(ctx.raw(), envelope)) {
|
||||
if (!parserSession->parse(ctx, envelope)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -540,7 +534,7 @@ bool PipelineEngine::stage3Filter(softbus::core::models::DOMMessage& message)
|
||||
}
|
||||
|
||||
softbus::core::models::EnrichedMessage PipelineEngine::applyTransformAndEnrich(
|
||||
const PipelineContext& rawCtx, softbus::core::models::DOMMessage& message) const
|
||||
const softbus::core::models::RawBusMessage& rawCtx, softbus::core::models::DOMMessage& message) const
|
||||
{
|
||||
auto rules = softbus::message_bus::pipeline::DynamicRuleRegistry::instance().snapshotTransformRules(
|
||||
rawCtx.endpoint, rawCtx.deviceId, rawCtx.stableKey);
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#include "core/plugin_system/IProtocolMapperPlugin.h"
|
||||
#include "core/models/DOMMessage.h"
|
||||
#include "core/models/EnrichedMessage.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
#include "core/memory/LockFreeQueue.h"
|
||||
#include "core/memory/MemoryPool.h"
|
||||
#include "core/threading/MutexQueue.h"
|
||||
#include "message_bus/pipeline/DynamicRuleRegistry.h"
|
||||
#include "message_bus/pipeline/PipelineContext.h"
|
||||
#include "message_bus/pipeline/stages/1_framers/PassthroughFramer.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline
|
||||
@@ -56,10 +56,10 @@ public:
|
||||
void stop();
|
||||
void drain();
|
||||
|
||||
bool enqueueIngress(PipelineContext ctx);
|
||||
bool enqueueEgress(PipelineContext ctx);
|
||||
bool enqueueIngress(softbus::core::models::RawBusMessage ctx);
|
||||
bool enqueueEgress(softbus::core::models::RawBusMessage ctx);
|
||||
|
||||
bool tryPopEgress(PipelineContext& out);
|
||||
bool tryPopEgress(softbus::core::models::RawBusMessage& out);
|
||||
void setPluginManager(std::shared_ptr<softbus::core::plugin_system::PluginManager> pluginManager);
|
||||
void setMemoryPool(std::shared_ptr<softbus::core::memory::MemoryPool> pool);
|
||||
void setRuntimeConfig(PipelineRuntimeConfig cfg);
|
||||
@@ -72,14 +72,14 @@ private:
|
||||
{
|
||||
QString endpoint;
|
||||
std::uint64_t seq{0};
|
||||
PipelineContext ctx;
|
||||
softbus::core::models::RawBusMessage ctx;
|
||||
bool pipelineOk{false};
|
||||
};
|
||||
|
||||
struct MergeState
|
||||
{
|
||||
std::uint64_t nextExpected{1};
|
||||
QHash<std::uint64_t, std::pair<PipelineContext, bool>> buffer;
|
||||
QHash<std::uint64_t, std::pair<softbus::core::models::RawBusMessage, bool>> buffer;
|
||||
};
|
||||
|
||||
void runSingleWorker();
|
||||
@@ -88,20 +88,21 @@ private:
|
||||
|
||||
void ensureEndpointFramer(const QString& endpoint);
|
||||
|
||||
void dispatchFramer(PipelineContext& chunkIn, std::vector<PipelineContext>& completeFramesOut);
|
||||
void assignFrameSequence(PipelineContext& ctx);
|
||||
bool runStages234(PipelineContext& ctx);
|
||||
void dispatchFramer(softbus::core::models::RawBusMessage& chunkIn,
|
||||
std::vector<softbus::core::models::RawBusMessage>& completeFramesOut);
|
||||
std::uint64_t assignFrameSequence(const QString& endpoint);
|
||||
bool runStages234(const softbus::core::models::RawBusMessage& ctx);
|
||||
void ingestMergeItem(MergeItem item);
|
||||
|
||||
std::vector<softbus::core::models::DOMMessage> stage2Parser(const PipelineContext& ctx);
|
||||
std::vector<softbus::core::models::DOMMessage> stage2Parser(const softbus::core::models::RawBusMessage& ctx);
|
||||
bool stage3Filter(softbus::core::models::DOMMessage& message);
|
||||
bool stage4Validator(const softbus::core::models::DOMMessage& message) const;
|
||||
softbus::core::models::EnrichedMessage applyTransformAndEnrich(
|
||||
const PipelineContext& rawCtx, softbus::core::models::DOMMessage& message) const;
|
||||
const softbus::core::models::RawBusMessage& rawCtx, softbus::core::models::DOMMessage& message) const;
|
||||
|
||||
private:
|
||||
softbus::core::memory::LockFreeQueue<PipelineContext> m_ingressQ;
|
||||
softbus::core::memory::LockFreeQueue<PipelineContext> m_egressQ;
|
||||
softbus::core::memory::LockFreeQueue<softbus::core::models::RawBusMessage> m_ingressQ;
|
||||
softbus::core::memory::LockFreeQueue<softbus::core::models::RawBusMessage> m_egressQ;
|
||||
std::atomic<bool> m_running{false};
|
||||
std::thread m_worker;
|
||||
Counters m_counters;
|
||||
@@ -121,7 +122,7 @@ private:
|
||||
std::mutex m_seqMutex;
|
||||
QHash<QString, std::uint64_t> m_nextFrameSeqByEndpoint;
|
||||
|
||||
std::unique_ptr<softbus::core::threading::MutexQueue<PipelineContext>> m_framedQ;
|
||||
std::unique_ptr<softbus::core::threading::MutexQueue<MergeItem>> m_framedQ;
|
||||
std::unique_ptr<softbus::core::threading::MutexQueue<MergeItem>> m_mergeQ;
|
||||
std::vector<std::thread> m_parseThreads;
|
||||
std::thread m_mergerThread;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "message_bus/pipeline/PipelineContext.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline::stages::framers
|
||||
{
|
||||
@@ -13,8 +13,8 @@ public:
|
||||
virtual ~IFramer() = default;
|
||||
|
||||
/// Consumes `chunkIn` (StreamChunk 语义);仅在 `completeFramesOut` 中追加 CompleteFrame。
|
||||
virtual void feed(softbus::message_bus::pipeline::PipelineContext& chunkIn,
|
||||
std::vector<softbus::message_bus::pipeline::PipelineContext>& completeFramesOut) = 0;
|
||||
virtual void feed(softbus::core::models::RawBusMessage& chunkIn,
|
||||
std::vector<softbus::core::models::RawBusMessage>& completeFramesOut) = 0;
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline::stages::framers
|
||||
|
||||
@@ -10,8 +10,8 @@ PassthroughFramer::PassthroughFramer(std::shared_ptr<softbus::core::memory::Memo
|
||||
{
|
||||
}
|
||||
|
||||
void PassthroughFramer::feed(softbus::message_bus::pipeline::PipelineContext& chunkIn,
|
||||
std::vector<softbus::message_bus::pipeline::PipelineContext>& completeFramesOut)
|
||||
void PassthroughFramer::feed(softbus::core::models::RawBusMessage& chunkIn,
|
||||
std::vector<softbus::core::models::RawBusMessage>& completeFramesOut)
|
||||
{
|
||||
if (!m_pool || !chunkIn.payload.valid()) {
|
||||
return;
|
||||
@@ -31,7 +31,7 @@ void PassthroughFramer::feed(softbus::message_bus::pipeline::PipelineContext&
|
||||
std::memcpy(blk->data, src, n);
|
||||
blk->size = n;
|
||||
|
||||
softbus::message_bus::pipeline::PipelineContext out;
|
||||
softbus::core::models::RawBusMessage out;
|
||||
out.deviceId = chunkIn.deviceId;
|
||||
out.stableKey = chunkIn.stableKey;
|
||||
out.endpoint = chunkIn.endpoint;
|
||||
@@ -39,7 +39,6 @@ void PassthroughFramer::feed(softbus::message_bus::pipeline::PipelineContext&
|
||||
out.protocolHint = chunkIn.protocolHint;
|
||||
out.traceId = chunkIn.traceId;
|
||||
out.direction = chunkIn.direction;
|
||||
out.frameKind = softbus::message_bus::pipeline::FrameKind::CompleteFrame;
|
||||
out.payloadSize = n;
|
||||
out.payload.block = std::move(blk);
|
||||
out.payload.offset = 0;
|
||||
|
||||
@@ -15,8 +15,8 @@ class PassthroughFramer final : public IFramer
|
||||
public:
|
||||
explicit PassthroughFramer(std::shared_ptr<softbus::core::memory::MemoryPool> pool);
|
||||
|
||||
void feed(softbus::message_bus::pipeline::PipelineContext& chunkIn,
|
||||
std::vector<softbus::message_bus::pipeline::PipelineContext>& completeFramesOut) override;
|
||||
void feed(softbus::core::models::RawBusMessage& chunkIn,
|
||||
std::vector<softbus::core::models::RawBusMessage>& completeFramesOut) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<softbus::core::memory::MemoryPool> m_pool;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "core/models/DOMMessage.h"
|
||||
#include "message_bus/pipeline/PipelineContext.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline::stages::parsers
|
||||
{
|
||||
@@ -13,7 +13,7 @@ class IParserStage
|
||||
public:
|
||||
virtual ~IParserStage() = default;
|
||||
virtual std::vector<softbus::core::models::DOMMessage> parse(
|
||||
const softbus::message_bus::pipeline::PipelineContext& rawContext) = 0;
|
||||
const softbus::core::models::RawBusMessage& rawContext) = 0;
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline::stages::parsers
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "message_bus/pipeline/PipelineContext.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline::stages::validators
|
||||
{
|
||||
@@ -9,7 +9,7 @@ class IValidator
|
||||
{
|
||||
public:
|
||||
virtual ~IValidator() = default;
|
||||
virtual bool validate(softbus::message_bus::pipeline::PipelineContext& ctx) = 0;
|
||||
virtual bool validate(softbus::core::models::RawBusMessage& ctx) = 0;
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline::stages::validators
|
||||
|
||||
Reference in New Issue
Block a user