Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
siarheivesialou committed Jun 20, 2024
1 parent 1ef051d commit eb7d7c4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
14 changes: 14 additions & 0 deletions ydb/core/http_proxy/http_req.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,20 @@ namespace NKikimr::NHttpProxy {

RpcFuture.Subscribe([actorId = ctx.SelfID, actorSystem = ctx.ActorSystem()]
(const NThreading::TFuture<TProtoResponse>& future) {

// auto& response = future.GetValueSync();
// auto result = MakeHolder<TEvServerlessProxy::TEvGrpcRequestResult>();
// Y_ABORT_UNLESS(response.operation().ready());
// if (response.operation().status() == Ydb::StatusIds::SUCCESS) {
// TProtoResult rs;
// response.operation().result().UnpackTo(&rs);
// result->Message = MakeHolder<TProtoResult>(rs);
// }
// NYql::TIssues issues;
// NYql::IssuesFromMessage(response.operation().issues(), issues);
// result->Status = MakeHolder<NYdb::TStatus>(NYdb::EStatus(response.operation().status()),
// std::move(issues));
// actorSystem->Send(actorId, result.Release());
Cerr << "KLACK TLocalRpccHttpRequestActor::SendGrpcRequestNoDriver(): got reply\n";
auto& response = future.GetValueSync();
auto result = MakeHolder<TEvServerlessProxy::TEvGrpcRequestResult>();
Expand Down
18 changes: 16 additions & 2 deletions ydb/library/http_proxy/error/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@
namespace NKikimr::NSQS {

THashSet<TString> TErrorClass::RegisteredCodes;
THashMap<ui32, TErrorClass*> TErrorClass::IdToErrorClass;

TErrorClass::TErrorClass(TString errorCode, ui32 httpStatusCode, TString defaultMessage)
: ErrorCode(std::move(errorCode))
, HttpStatusCode(httpStatusCode)
, DefaultMessage(std::move(defaultMessage))
, Id(httpStatusCode)
{
RegisteredCodes.insert(ErrorCode);
}

TErrorClass::TErrorClass(TString errorCode, ui32 httpStatusCode, TString defaultMessage, ui32 id)
: ErrorCode(std::move(errorCode))
, HttpStatusCode(httpStatusCode)
, DefaultMessage(std::move(defaultMessage))
, Id(id)
{
RegisteredCodes.insert(ErrorCode);
IdToErrorClass.insert_or_assign(id, this);
}

TSQSException::TSQSException(const TErrorClass& errorClass)
Expand Down Expand Up @@ -116,7 +128,8 @@ extern const TErrorClass SERVICE_UNAVAILABLE = {
extern const TErrorClass THROTTLING_EXCEPTION = {
"ThrottlingException",
403,
"The request was denied due to request throttling."
"The request was denied due to request throttling.",
1
};

extern const TErrorClass VALIDATION_ERROR = {
Expand Down Expand Up @@ -158,7 +171,8 @@ extern const TErrorClass BATCH_REQUEST_TOO_LONG = {
extern const TErrorClass NON_EXISTENT_QUEUE = {
"AWS.SimpleQueueService.NonExistentQueue",
400,
"The specified queue doesn't exist."
"The specified queue doesn't exist.",
2
};

extern const TErrorClass OVER_LIMIT = {
Expand Down
3 changes: 3 additions & 0 deletions ydb/library/http_proxy/error/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ struct TErrorClass {
const TString ErrorCode;
const ui32 HttpStatusCode;
const TString DefaultMessage;
const ui32 Id;

TErrorClass(TString errorCode, ui32 httpStatusCode, TString defaultMessage);
TErrorClass(TString errorCode, ui32 httpStatusCode, TString defaultMessage, ui32 id);
TErrorClass() = delete;
TErrorClass(const TErrorClass&) = delete;
TErrorClass(TErrorClass&&) = delete;
Expand All @@ -20,6 +22,7 @@ struct TErrorClass {
return RegisteredCodes;
}

static THashMap<ui32, TErrorClass*> IdToErrorClass;
private:
static THashSet<TString> RegisteredCodes;
};
Expand Down
15 changes: 13 additions & 2 deletions ydb/services/ymq/ymq_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,21 @@ namespace NKikimr::NYmq::V1 {
Cerr << "KLACK TYmqReplyCallback::TYmqReplyCallback()\n";
}
void DoSendReply(const NKikimrClient::TSqsResponse& resp) {
if (resp.GetGetQueueUrl().HasError()) {
NYql::TIssue issue(resp.GetGetQueueUrl().GetError().GetErrorCode());
issue.SetCode(3, NYql::ESeverity::TSeverityIds_ESeverityId_S_ERROR);
issue.SetMessage(resp.GetGetQueueUrl().GetError().GetMessage());
Cerr << "KLACK resp.GetGetQueueUrl().GetError().GetErrorCode() == " << resp.GetGetQueueUrl().GetError().GetErrorCode() << " \n";
Cerr << "KLACK resp.GetGetQueueUrl().GetError().GetMessage() == " << resp.GetGetQueueUrl().GetError().GetMessage() << " \n";
Cerr << "KLACK resp.GetGetQueueUrl().GetError().GetStatus() == " << resp.GetGetQueueUrl().GetError().GetStatus() << " \n";
Request->RaiseIssue(issue);
} else {
Ydb::Ymq::V1::GetQueueUrlResult result;
result.Setqueue_url(resp.GetGetQueueUrl().GetQueueUrl());
Request->SendResult(result, Ydb::StatusIds::StatusCode::StatusIds_StatusCode_SUCCESS);
}
Cerr << "KLACK TYmqReplyCallback::DoSendReply(): " << resp.AsJSON() << "\n";
Ydb::Ymq::V1::GetQueueUrlResult result;
//TODO: возвращать правильный ответ
Request->SendResult(result, Ydb::StatusIds::StatusCode::StatusIds_StatusCode_SUCCESS);
}
private:
std::shared_ptr<NKikimr::NGRpcService::IRequestOpCtx> Request;
Expand Down

0 comments on commit eb7d7c4

Please sign in to comment.