/* * 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 #include #include namespace testutil { namespace testservice { class TestStreamServiceMock : public apache::thrift::ServiceHandler { public: TestStreamServiceMock() {} int32_t echo(int32_t value) override; apache::thrift::ServerStream range( int32_t from, int32_t to) override; apache::thrift::ServerStream buffers(int32_t count) override; apache::thrift::ServerStream customBuffers( int32_t count, int32_t size) override; apache::thrift::ServerStream slowRange( int32_t from, int32_t to, int32_t millis) override; apache::thrift::ServerStream slowCancellation() override; apache::thrift::ServerStream returnNullptr() override; apache::thrift::ResponseAndServerStream throwError() override; apache::thrift::ResponseAndServerStream leakCheck( int32_t from, int32_t to) override; apache::thrift::ResponseAndServerStream leakCheckWithSleep( int32_t from, int32_t to, int32_t sleepMs) override; int32_t instanceCount() override; apache::thrift::ResponseAndServerStream sleepWithResponse( int32_t timeMs) override; apache::thrift::ServerStream sleepWithoutResponse( int32_t timeMs) override; apache::thrift::ResponseAndServerStream streamServerSlow() override; void sendMessage(int32_t messageId, bool complete, bool error) override; apache::thrift::ServerStream registerToMessages() override; apache::thrift::ServerStream streamThrows(int32_t whichEx) override; apache::thrift::ResponseAndServerStream responseAndStreamThrows(int32_t whichEx) override; apache::thrift::ServerStream requestWithBlob( std::unique_ptr val) override; void async_eb_leakCallback( apache::thrift::HandlerCallbackPtr>) override; void async_eb_orderRequestStream( apache::thrift::HandlerCallbackPtr< apache::thrift::ResponseAndServerStream>) override; void async_eb_orderRequestResponse( apache::thrift::HandlerCallbackPtr) override; apache::thrift::ServerStream leakPublisherCheck() override; protected: folly::ScopedEventBaseThread executor_; std::unique_ptr> messages_; std::atomic order_{0}; folly::Synchronized< std::unique_ptr>> publisher_; }; } // namespace testservice } // namespace testutil