Skip to content

Commit

Permalink
Add review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Thushani-Jayasekera committed Jun 3, 2024
1 parent a332025 commit fc6d6e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,6 @@ FilterHeadersStatus MgwWebSocketContext::onRequestHeaders(uint32_t, bool) {
if (buffer.has_value() && buffer.value()->size() != 0) {
auto pairs = buffer.value()->pairs();
for (auto &p : pairs) {
// TODO (thushani) Implement fixes for throttling

// if (std::string(p.first) == "isThrottled" && std::string(p.second) == "true") {
// LOG_TRACE(std::string("Initial throttle state is overlimit for the request : ") + this->x_request_id_);
// this->throttle_state_ = ThrottleState::OverLimit;
// } else if (std::string(p.first) == INITIAL_APIM_ERROR_CODE) {
// int errorCode;
// sscanf(std::string(p.second).c_str(), "%d", &errorCode);
// this->apim_error_code_ = errorCode;
// LOG_TRACE(std::string("Initial APIM Error code is ") + std::string(p.second) + std::string(" for the request : ") + this->x_request_id_);
// } else if (std::string(p.first) == THROTTLE_CONDITION_EXPIRE_TIMESTAMP) {
// int timestamp;
// sscanf(std::string(p.second).c_str(), "%d", &timestamp);
// this->throttle_period_ = timestamp;
// LOG_TRACE(std::string("Throttle Period is till ") + std::string(p.second) + std::string(" for the request : ") + this->x_request_id_);
// } else if (std::string(p.first) == EXT_AUTHZ_DURATION) {
// LOG_TRACE(std::string("Ext Authz Duration Ignored!!!"));
// }

// The above metadata is only required for determining throttling state in the start. Hence they are not
// required to stored in metadata separately. Everything else will be stored under metadata.
(*this->metadata_->mutable_ext_authz_metadata())[std::string(p.first)] = std::string(p.second);
LOG_TRACE(std::string(p.first) + std::string(" -> ") + std::string(p.second) +
std::string(" dynamic metadata for the request : ") + this->x_request_id_);
Expand Down Expand Up @@ -164,7 +143,7 @@ FilterHeadersStatus MgwWebSocketContext::onResponseHeaders(uint32_t, bool) {
FilterDataStatus MgwWebSocketContext::onRequestBody(size_t body_buffer_length,
bool /* end_of_stream */) {
auto body = getBufferBytes(WasmBufferType::HttpRequestBody, 0, body_buffer_length);
LOG_TRACE(std::string("onRequestBody called mgw_WASM_websocket ") + std::string(body->view()) + std::string(" : ") + this->x_request_id_ );
LOG_TRACE(std::string("onRequestBody called mgw_WASM_websocket ") + std::string(" : ") + this->x_request_id_ );
auto data = body->view();

if(isDataFrame(data)){
Expand Down Expand Up @@ -291,7 +270,6 @@ FilterDataStatus MgwWebSocketContext::onResponseBody(size_t body_buffer_length,
LOG_ERROR(std::string("Current Time cannot be processed. Hence the websocket stream is closed. : ") +
this->x_request_id_);
return FilterDataStatus::StopIterationNoBuffer;
return FilterDataStatus::StopIterationNoBuffer;
}
}
}else{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void MgwGrpcStreamHandler::onRemoteClose(GrpcStatus status){
void MgwGrpcStreamHandler::sendMessage(WebSocketFrameRequest request){
auto res = send(request, true);
if(res != WasmResult::Ok){
LOG_TRACE(std::string("Error sending message"));
LOG_WARN(std::string("Error sending message"));
}else{
LOG_TRACE(std::string("Message sent successfully"));
};
Expand Down

0 comments on commit fc6d6e6

Please sign in to comment.