blob: c06f6cf8ce0d6608019c1dc3b837140487251379 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "mynetwork.h"
#include <vespa/messagebus/sendproxy.h>
class MyServiceAddress : public mbus::IServiceAddress {
private:
std::string _address;
public:
MyServiceAddress(const std::string &address) : _address(address) {}
const std::string &getAddress() { return _address; }
};
MyNetwork::MyNetwork(const mbus::RPCNetworkParams ¶ms) :
mbus::RPCNetwork(params),
_nodes()
{}
bool
MyNetwork::allocServiceAddress(mbus::RoutingNode &recipient)
{
recipient.setServiceAddress(mbus::IServiceAddress::UP(new MyServiceAddress(recipient.getRoute().getHop(0).toString())));
return true;
}
void
MyNetwork::freeServiceAddress(mbus::RoutingNode &recipient)
{
recipient.setServiceAddress(mbus::IServiceAddress::UP());
}
void
MyNetwork::send(const mbus::Message &msg, const std::vector<mbus::RoutingNode*> &nodes)
{
(void)msg;
_nodes.insert(_nodes.begin(), nodes.begin(), nodes.end());
}
void
MyNetwork::removeNodes(std::vector<mbus::RoutingNode*> &nodes)
{
nodes.insert(nodes.begin(), _nodes.begin(), _nodes.end());
_nodes.clear();
}
|