All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.StreamAPI.tpl Maven / Gradle / Ivy

The newest version!
<#if service.javaPackage?has_content>
  <#assign package = service.javaPackage>
<#else>
  <#assign package = service.packageName>

package ${package?c_lower_case};

<#if protocol == "GRPC">
import com.google.protobuf.Descriptors.FileDescriptor;

import com.tencent.trpc.core.rpc.RpcContext;
import com.tencent.trpc.core.rpc.anno.TRpcMethod;
import com.tencent.trpc.core.rpc.anno.TRpcService;
<#if protocol == "GRPC">
import io.grpc.stub.StreamObserver;
<#else>
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;


<#list service.messageTypes as name, msgType>
  <#if msgType.javaPackage?has_content>
    <#assign msgPackage = msgType.javaPackage>
  <#else>
    <#assign msgPackage = msgType.packageName>
  
  <#if msgType.multipleClasses>
    <#assign msgClass = msgType.name?cap_first>
  <#elseif msgType.javaOuterClass?has_content>
    <#assign msgClass = msgType.javaOuterClass + '.' + msgType.name?cap_first>
  <#else>
    <#assign msgClass = msgType.fallbackClassname + '.' + msgType.name?cap_first>
  
import ${msgPackage?c_lower_case}.${msgClass};


/**
 * Generated by trpc-java-codegen
 */
@TRpcService(name = "${service.packageName}.${service.name}")
public interface ${service.interfaceNamePrefix}StreamAPI {
<#if protocol == "GRPC">
  <#if !service.multipleClasses && service.javaOuterClass?has_content>
    <#assign serviceClass = service.javaOuterClass>
  <#else>
    <#assign serviceClass = service.fallbackClassname>
  

    /**
     * 用于获取pb文件描述信息
     *
     * @return pb文件描述信息
     */
    static FileDescriptor getDescriptor() {
        return ${serviceClass}.getDescriptor();
    }

<#list service.methods as method>
  <#assign methodName = method.name[0]?c_lower_case + method.name[1..]>

  <#if protocol == "GRPC">
    <#if method.clientStreaming>
    /**
     * ${method.name}
     *
     * @param context context
     * @param responseObserver responseObserver
     * @return requestObserver
     */
    @TRpcMethod(name = "${method.name}"<#if method.alias?has_content>, alias = {"${method.alias}"})
    StreamObserver<${method.inputType.name}> ${methodName}(RpcContext context, StreamObserver<${method.outputType.name}> responseObserver);
    <#elseif method.serverStreaming>
    /**
     * ${method.name}
     *
     * @param context context
     * @param request request
     * @param responseObserver responseObserver
     */
    @TRpcMethod(name = "${method.name}"<#if method.alias?has_content>, alias = {"${method.alias}"})
    void ${methodName}(RpcContext context, ${method.inputType.name} request, StreamObserver<${method.outputType.name}> responseObserver);
    
  <#elseif protocol == "TRPC">
    /**
     * ${method.name}
     *
     * @param context context
     * @param request request
     * @return {@link ${method.outputType.name}}
     */
    @TRpcMethod(name = "${method.name}"<#if method.alias?has_content>, alias = {"${method.alias}"})
    <#if method.serverStreaming>Flux<#else>Mono<${method.outputType.name}> ${method.name[0]?c_lower_case + method.name[1..]}(RpcContext context, <#if method.clientStreaming>Publisher<${method.inputType.name}><#else>${method.inputType.name} request);
  

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy