blob: f6d79b280a0ecded36f4698ecd8ba24e208bd47a (
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
|
#include "schema.h"
namespace NSQLComplete {
namespace {
class TSchema: public ISchema {
public:
explicit TSchema(THashMap<TString, ISchema::TPtr> mapping)
: Mapping_(std::move(mapping))
{
}
NThreading::TFuture<TListResponse> List(const TListRequest& request) const override {
auto iter = Mapping_.find(request.Cluster);
if (iter == std::end(Mapping_)) {
yexception e;
e << "unknown cluster '" << request.Cluster << "'";
std::exception_ptr p = std::make_exception_ptr(e);
return NThreading::MakeErrorFuture<TListResponse>(p);
}
return iter->second->List(request);
}
private:
THashMap<TString, ISchema::TPtr> Mapping_;
};
} // namespace
ISchema::TPtr MakeDispatchSchema(THashMap<TString, ISchema::TPtr> mapping) {
return new TSchema(std::move(mapping));
}
} // namespace NSQLComplete
|