@@ -249,6 +249,7 @@ void SetIdempotencyKey(T& dst, const TString& key) {
249
249
250
250
template <typename GrpcProtoRequestType, typename HttpProtoRequestType, typename GrpcProtoResultType, typename HttpProtoResultType, typename GrpcProtoResponseType>
251
251
class TGrpcCallWrapper : public TActorBootstrapped <TGrpcCallWrapper<GrpcProtoRequestType, HttpProtoRequestType, GrpcProtoResultType, HttpProtoResultType, GrpcProtoResponseType>> {
252
+ protected:
252
253
THttpRequestContext RequestContext;
253
254
254
255
typedef std::function<std::unique_ptr<NGRpcService::TEvProxyRuntimeEvent>(TIntrusivePtr<NYdbGrpc::IRequestContextBase> ctx)> TGrpcProxyEventFactory;
@@ -349,14 +350,13 @@ class TGrpcCallWrapper : public TActorBootstrapped<TGrpcCallWrapper<GrpcProtoReq
349
350
Y_ABORT_UNLESS (resp->GetArena ());
350
351
Y_UNUSED (status);
351
352
auto * typedResponse = static_cast <TGrpcProtoResponseType*>(resp);
352
- if (!typedResponse->operation ().result ().template Is <TGrpcProtoResultType>()) {
353
- TStringStream json;
354
- auto * httpResult = google::protobuf::Arena::CreateMessage<FQHttp::Error>(resp->GetArena ());
355
- FqConvert (typedResponse->operation (), *httpResult);
356
- FqPackToJson (json, *httpResult, jsonSettings);
357
-
358
- requestContext.ResponseBadRequestJson (typedResponse->operation ().status (), json.Str ());
359
- return ;
353
+ if (!typedResponse->operation ().result ().template Is <TGrpcProtoResultType>()) {
354
+ TStringStream json;
355
+ auto * httpResult = google::protobuf::Arena::CreateMessage<FQHttp::Error>(resp->GetArena ());
356
+ FqConvert (typedResponse->operation (), *httpResult);
357
+ FqPackToJson (json, *httpResult, jsonSettings);
358
+ requestContext.ResponseBadRequestJson (typedResponse->operation ().status (), json.Str ());
359
+ return ;
360
360
}
361
361
362
362
auto * grpcResult = google::protobuf::Arena::CreateMessage<TGrpcProtoResultType>(resp->GetArena ());
@@ -396,4 +396,71 @@ DECLARE_YQ_GRPC_ACTOR(GetQueryStatus, GetQueryStatus);
396
396
DECLARE_YQ_GRPC_ACTOR_WIHT_EMPTY_RESULT (StopQuery, ControlQuery);
397
397
DECLARE_YQ_GRPC_ACTOR (GetResultData, GetResultData);
398
398
399
+ #define TGrpcCallWrapperBase TGrpcCallWrapper<FederatedQuery::DescribeQueryRequest, FQHttp::GetQueryRequest, FederatedQuery::ModifyQueryResult, google::protobuf::Empty, FederatedQuery::ModifyQueryResponse>
400
+
401
+ class TStartQueryRequest : public TGrpcCallWrapperBase {
402
+ public:
403
+ TStartQueryRequest (const THttpRequestContext& ctx)
404
+ : TGrpcCallWrapperBase(ctx, &NGRpcService::CreateFederatedQueryDescribeQueryRequestOperationCall)
405
+ {}
406
+
407
+ void Bootstrap (const TActorContext& ctx) {
408
+ auto describeRequest = std::make_unique<FederatedQuery::DescribeQueryRequest>();
409
+ if (!Parse (*describeRequest)) {
410
+ this ->Die (ctx);
411
+ return ;
412
+ }
413
+
414
+ TIntrusivePtr<TGrpcRequestContextWrapper> requestContext = new TGrpcRequestContextWrapper (
415
+ RequestContext,
416
+ std::move (describeRequest),
417
+ [&, this , query_id = describeRequest->Getquery_id ()](const THttpRequestContext& requestContext, const TJsonSettings& jsonSettings, NProtoBuf::Message* resp, ui32 status) {
418
+ Y_ABORT_UNLESS (resp);
419
+ Y_ABORT_UNLESS (resp->GetArena ());
420
+
421
+ auto * typedResponse = static_cast <FederatedQuery::DescribeQueryResponse*>(resp);
422
+ if (!typedResponse->operation ().result ().template Is <FederatedQuery::DescribeQueryResult>()) {
423
+ TStringStream json;
424
+ auto * httpResult = google::protobuf::Arena::CreateMessage<FQHttp::Error>(resp->GetArena ());
425
+ FqConvert (typedResponse->operation (), *httpResult);
426
+ FqPackToJson (json, *httpResult, jsonSettings);
427
+ requestContext.ResponseBadRequestJson (typedResponse->operation ().status (), json.Str ());
428
+ this ->Die (ctx);
429
+ return ;
430
+ }
431
+
432
+ FederatedQuery::DescribeQueryResult* describeResult = google::protobuf::Arena::CreateMessage<FederatedQuery::DescribeQueryResult>(resp->GetArena ());
433
+ typedResponse->operation ().result ().UnpackTo (describeResult);
434
+
435
+
436
+ // modify
437
+ auto modifyRequest = std::unique_ptr<FederatedQuery::ModifyQueryRequest>(google::protobuf::Arena::CreateMessage<FederatedQuery::ModifyQueryRequest>(resp->GetArena ()));
438
+
439
+ modifyRequest->set_query_id (query_id);
440
+ auto content = describeResult->Getquery ().content ();
441
+ modifyRequest->set_allocated_content (&content);
442
+ modifyRequest->set_execute_mode (::FederatedQuery::ExecuteMode::RUN);
443
+ modifyRequest->set_allocated_disposition (nullptr );
444
+ modifyRequest->set_state_load_mode (::FederatedQuery::StateLoadMode::STATE_LOAD_MODE_UNSPECIFIED);
445
+ modifyRequest->set_previous_revision (describeResult->Getquery ().meta ().Getlast_job_query_revision ());
446
+ modifyRequest->set_idempotency_key (requestContext.GetIdempotencyKey ());
447
+
448
+ TIntrusivePtr<TGrpcRequestContextWrapper> requestContextModify = new TGrpcRequestContextWrapper (
449
+ this ->RequestContext ,
450
+ std::move (modifyRequest),
451
+ TGrpcCallWrapper<FederatedQuery::ModifyQueryRequest, int , FederatedQuery::ModifyQueryResult, google::protobuf::Empty, FederatedQuery::ModifyQueryResponse>::SendReply
452
+ );
453
+
454
+ // new event -> new EventFactory
455
+ EventFactory = &NGRpcService::CreateFederatedQueryModifyQueryRequestOperationCall;
456
+ ctx.Send (NGRpcService::CreateGRpcRequestProxyId (), EventFactory (requestContextModify).release ());
457
+ this ->Die (ctx);
458
+ });
459
+
460
+ ctx.Send (NGRpcService::CreateGRpcRequestProxyId (), EventFactory (requestContext).release ());
461
+ }
462
+ };
463
+
464
+ #undef TGrpcCallWrapperBase
465
+
399
466
} // namespace NKikimr::NPublicHttp
0 commit comments