{{! Copyright (c) Meta Platforms, Inc. and its 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.thrift.client.*; import java.util.*; public class {{service:javaCapitalName}}BlockingReactiveWrapper {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}BlockingReactiveWrapper{{/service:extends}} implements {{service:javaCapitalName}}.Reactive { private final {{service:javaCapitalName}} _delegate; public {{service:javaCapitalName}}BlockingReactiveWrapper({{service:javaCapitalName}} _delegate) { {{#service:extends}}super(_delegate);{{/service:extends}} this._delegate = _delegate; } @java.lang.Override public void dispose() { _delegate.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { {{#function:voidType}} reactor.core.publisher.Mono _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); _sink.success(); } catch (Throwable _e) { throw reactor.core.Exceptions.propagate(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} {{^function:voidType}} reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _sink.success(_delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}})); } catch (Throwable _e) { _sink.error(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} {{#service:sinkFunctions}} @java.lang.Override public {{#function:return_type}}{{> SinkReturnType}}{{/function:return_type}} {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}} org.reactivestreams.Publisher<{{#function:return_type}}{{#function:sink_elem_type}}{{ >BoxedType}}{{/function:sink_elem_type}}{{/function:return_type}}> payloads) { throw new UnsupportedOperationException(); } {{/service:sinkFunctions}} {{#service:interactions}} public class {{service:name}}Impl implements {{service:name}} { private {{service:javaParentCapitalName}}.{{service:name}} _delegateInteraction; {{service:name}}Impl({{service:javaParentCapitalName}}.{{service:name}} delegateInteraction) { this._delegateInteraction = delegateInteraction; } {{#service:singleRequestFunctions}} @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { {{#function:voidType}} reactor.core.publisher.Mono _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}); _sink.success(); } catch (Throwable _e) { throw reactor.core.Exceptions.propagate(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} {{^function:voidType}} reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> _m = reactor.core.publisher.Mono.create(_sink -> { try { reactor.util.context.ContextView _contextView = _sink.contextView(); com.facebook.nifty.core.RequestContext .tryContextView(_contextView) .ifPresent(com.facebook.nifty.core.RequestContexts::setCurrentContext); _sink.success(_delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}})); } catch (Throwable _e) { _sink.error(_e); } }); if (!com.facebook.thrift.util.resources.RpcResources.isForceExecutionOffEventLoop()) { _m = _m.subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler()); } return _m; {{/function:voidType}} } @java.lang.Override public reactor.core.publisher.Mono<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } @java.lang.Override public reactor.core.publisher.Mono BoxedType}}{{/function:return_type}}>> {{function:javaName}}Wrapper({{#function:args}} final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}, {{/function:args}}RpcOptions rpcOptions) { throw new UnsupportedOperationException(); } {{/service:singleRequestFunctions}} {{#service:streamingFunctions}} @java.lang.Override public reactor.core.publisher.Flux<{{#function:return_type}}{{> StreamReturnType}}{{/function:return_type}}> {{function:javaName}}({{#function:args}}final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}}) { throw new UnsupportedOperationException(); } {{/service:streamingFunctions}} @java.lang.Override public void dispose() {} } public {{service:name}} create{{service:name}}() { return new {{service:name}}Impl(_delegate.create{{service:name}}()); } {{^last?}} {{/last?}} {{/service:interactions}} }