aboutsummaryrefslogtreecommitdiffstats
path: root/ydb/library/yql/providers/external_function/gateway/dq_function_gateway.cpp
blob: 518c0c9e404368677fc91e2cfd50af362603a7e4 (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
#include "dq_function_gateway.h"

#include <ydb/library/yql/utils/yql_panic.h>

namespace NYql {

void TDqFunctionGatewayFactory::Register(const TDqFunctionType& type, TGatewayCreator creator) {
    auto [_, registered] = CreatorsByType.emplace(type, std::move(creator));
    Y_VERIFY(registered);
}

bool TDqFunctionGatewayFactory::IsKnownFunctionType(const TDqFunctionType& type) {
    return !type.empty() && CreatorsByType.contains(type);
}

IDqFunctionGateway::TPtr TDqFunctionGatewayFactory::CreateDqFunctionGateway(
        const TDqFunctionType& type, const THashMap<TString, TString>& secureParams,
        const TString& connection) const {

    auto creator = CreatorsByType.find(type);
    if (creator == CreatorsByType.end()) {
        YQL_ENSURE(false, "Unregistered external function gateway type " << type);
    }
    return (creator->second)(secureParams, connection);
}

}