/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include namespace apache { namespace thrift { namespace stress { class StressTestHandler : public apache::thrift::ServiceHandler { public: StressTestHandler(); void async_eb_ping(HandlerCallbackPtr callback) override; void async_tm_echo( HandlerCallbackPtr> callback, std::unique_ptr<::std::string> payload) override { callback->result(std::move(payload)); } void async_eb_echoEb( HandlerCallbackPtr> callback, std::unique_ptr<::std::string> payload) override { callback->result(std::move(payload)); } void async_tm_requestResponseTm( HandlerCallbackPtr> callback, std::unique_ptr request) override; void async_eb_requestResponseEb( HandlerCallbackPtr> callback, std::unique_ptr request) override; ResponseAndServerStream streamTm( std::unique_ptr request) override; ResponseAndSinkConsumer sinkTm( std::unique_ptr request) override; private: void requestResponseImpl( HandlerCallbackPtr> callback, std::unique_ptr request) const; void simulateWork(int64_t timeMs, WorkSimulationMode mode) const; folly::coro::Task co_simulateWork( int64_t timeMs, WorkSimulationMode mode) const; void busyWait(std::chrono::milliseconds duration) const; BasicResponse makeBasicResponse(int64_t payloadSize) const; }; } // namespace stress } // namespace thrift } // namespace apache