thrift/compiler/generate/templates/java/BlockingReactiveWrapper.mustache (117 lines of code) (raw):
{{!
Copyright (c) Facebook, 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}}
return reactor.core.publisher.Mono.<Void>fromRunnable(() -> {
try {
_delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
} catch (Throwable _e) {
throw reactor.core.Exceptions.propagate(_e);
}
}).subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler());
{{/function:voidType}}
{{^function:voidType}}
return reactor.core.publisher.Mono.fromSupplier(() -> {
try {
return _delegate.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
} catch (Throwable _e) {
throw reactor.core.Exceptions.propagate(_e);
}
}).subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler());
{{/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}}{{#type:sink_elem_type}}{{ >BoxedType}}{{/type:sink_elem_type}}{{/function:return_type}}> payloads) {
throw new UnsupportedOperationException();
}
{{/service:sinkFunctions}}
{{#service:interactions}}
public class {{service:name}}Impl implements {{service:name}} {
private {{service:parent}}.{{service:name}} _delegateInteraction;
{{service:name}}Impl({{service:parent}}.{{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}}
return reactor.core.publisher.Mono.<Void>fromRunnable(() -> {
try {
_delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
} catch (Throwable _e) {
throw reactor.core.Exceptions.propagate(_e);
}
}).subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler());
{{/function:voidType}}
{{^function:voidType}}
return reactor.core.publisher.Mono.fromSupplier(() -> {
try {
return _delegateInteraction.{{function:javaName}}({{#function:args}}{{field:javaName}}{{^last?}}, {{/last?}}{{/function:args}});
} catch (Throwable _e) {
throw reactor.core.Exceptions.propagate(_e);
}
}).subscribeOn(com.facebook.thrift.util.resources.RpcResources.getOffLoopScheduler());
{{/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<ResponseWrapper<{{#function:return_type}}{{> 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}}
}