{{! 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. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.nifty.client.RequestChannel; import com.facebook.swift.codec.*; import com.facebook.swift.service.*; import com.facebook.swift.service.metadata.*; import com.facebook.thrift.client.*; import com.facebook.thrift.util.FutureUtil; import com.google.common.util.concurrent.ListenableFuture; import java.io.*; import java.lang.reflect.Method; import java.util.*; import org.apache.thrift.ProtocolId; import reactor.core.publisher.Mono; @SwiftGenerated @Deprecated public class {{service:javaCapitalName}}AsyncClientImpl extends {{^service:extends}}AbstractThriftClient{{/service:extends}}{{#service:extends}}{{service:javaPackage}}.{{service:javaCapitalName}}AsyncClientImpl{{/service:extends}} implements {{service:javaCapitalName}}.Async { // Method Handlers {{#service:singleRequestFunctions}} private ThriftMethodHandler {{function:javaName}}MethodHandler; {{/service:singleRequestFunctions}} // Method Exceptions {{#service:singleRequestFunctions}} private static final Class[] {{function:javaName}}Exceptions = new Class[] { {{#function:exceptions}}{{#field:type}}{{> BoxedType}}.class{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException.class}; {{/service:singleRequestFunctions}} public {{service:javaCapitalName}}AsyncClientImpl( RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { this("{{service:name}}", channel, methods, headers, persistentHeaders, eventHandlers); } public {{service:javaCapitalName}}AsyncClientImpl( String serviceName, RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { {{^service:extends}}super(serviceName, channel, headers, persistentHeaders, eventHandlers);{{/service:extends}}{{#service:extends}}super(serviceName, channel, methods, headers, persistentHeaders, eventHandlers);{{/service:extends}} Map methodHandlerMap = new HashMap<>(); methods.forEach( (key, value) -> { methodHandlerMap.put(key.getName(), value); }); // Set method handlers {{#service:singleRequestFunctions}} {{function:javaName}}MethodHandler = methodHandlerMap.get("{{function:javaName}}"); {{/service:singleRequestFunctions}} } @java.lang.Override public void close() { super.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}) { return {{function:javaName}}({{#function:args}}{{field:javaName}}, {{/function:args}}RpcOptions.EMPTY); } @java.lang.Override public ListenableFuture<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions) { return FutureUtil.transform({{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}rpcOptions)); } @java.lang.Override public ListenableFuture BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions) { try { return executeWrapperWithOptions({{function:javaName}}MethodHandler, {{function:javaName}}Exceptions, rpcOptions{{#function:args}}, {{field:javaName}}{{/function:args}}); } catch (Throwable t) { throw new RuntimeTException(t.getMessage(), t); } } {{/service:singleRequestFunctions}} {{#service:interactions}} public {{service:name}} create{{service:name}}() { throw new RuntimeException("create interaction is not supported"); } {{/service:interactions}} }