/* * 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. */ #include #include #include namespace interactions { namespace test { namespace thrift { struct SemiCalculatorHandler : apache::thrift::ServiceHandler { struct SemiAdditionHandler : apache::thrift::ServiceHandler::AdditionIf { int acc_{0}; Point pacc_; folly::SemiFuture semifuture_accumulatePrimitive( int32_t a) override { acc_ += a; return folly::makeSemiFuture(); } folly::SemiFuture semifuture_noop() override { return folly::makeSemiFuture(); } folly::SemiFuture semifuture_accumulatePoint( std::unique_ptr<::interactions::test::thrift::Point> a) override { *pacc_.x_ref() += *a->x_ref(); *pacc_.y_ref() += *a->y_ref(); return folly::makeSemiFuture(); } folly::SemiFuture semifuture_getPrimitive() override { return acc_; } folly::SemiFuture> semifuture_getPoint() override { return folly::copy_to_unique_ptr(pacc_); } }; std::unique_ptr createAddition() override { return std::make_unique(); } folly::SemiFuture semifuture_addPrimitive( int32_t a, int32_t b) override { return a + b; } void async_tm_newAddition( std::unique_ptr>> cb) override { auto handler = std::make_unique(); cb->result({std::move(handler)}); } void async_tm_initializedAddition( std::unique_ptr>> cb, int x) override { auto handler = std::make_unique(); handler->acc_ = x; cb->result({std::move(handler), x}); } void async_tm_stringifiedAddition( std::unique_ptr>>> cb, int x) override { auto handler = std::make_unique(); handler->acc_ = x; cb->result( {std::move(handler), folly::copy_to_unique_ptr(std::to_string(x))}); } }; struct SemiBlankServiceHandler : apache::thrift::ServiceHandler {}; } // namespace thrift } // namespace test } // namespace interactions