blob: 2d18bd0a588f5ad0dfb1bc75da13c42e5941eeac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* \class storage::MessageBusVisitorMessageSession
*
* \brief Implementation of a visitor message session using messagebus.
*/
#pragma once
#include "visitormessagesession.h"
#include "visitorthread.h"
#include "visitor.h"
#include <vespa/messagebus/sourcesession.h>
namespace documentapi {
class DocumentMessage;
}
namespace storage {
class MessageBusVisitorMessageSession : public VisitorMessageSession,
public mbus::IReplyHandler
{
public:
using UP = std::unique_ptr<MessageBusVisitorMessageSession>;
MessageBusVisitorMessageSession(Visitor& visitor, VisitorThread& thread)
: _visitor(visitor),
_visitorThread(thread)
{
}
void setSourceSession(mbus::SourceSession::UP sourceSession) {
_sourceSession = std::move(sourceSession);
}
mbus::Result send(std::unique_ptr<documentapi::DocumentMessage> msg) override {
msg->setRetryEnabled(false);
return _sourceSession->send(std::move(msg));
}
uint32_t pending() override {
return _sourceSession->getPendingCount();
}
void handleReply(mbus::Reply::UP reply) override {
_visitorThread.handleMessageBusReply(std::move(reply), _visitor);
}
private:
Visitor& _visitor;
VisitorThread& _visitorThread;
mbus::SourceSession::UP _sourceSession;
};
} // storage
|