blob: 4929d4efd981e771b7ff76085d0e9209a1fbffe3 (
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
|
#include "rpc.h"
#include "multi.h"
#include "location.h"
#include "factory.h"
#include <util/string/cast.h>
#include <util/generic/hash.h>
using namespace NNeh;
namespace {
namespace NMulti {
class TRequester: public IRequester {
public:
inline TRequester(const TListenAddrs& addrs, IOnRequest* cb) {
for (const auto& addr : addrs) {
TParsedLocation loc(addr);
IRequesterRef& req = R_[ToString(loc.Scheme) + ToString(loc.GetPort())];
if (!req) {
req = ProtocolFactory()->Protocol(loc.Scheme)->CreateRequester(cb, loc);
}
}
}
private:
typedef THashMap<TString, IRequesterRef> TRequesters;
TRequesters R_;
};
}
}
IRequesterRef NNeh::MultiRequester(const TListenAddrs& addrs, IOnRequest* cb) {
return new NMulti::TRequester(addrs, cb);
}
|