Skip to content

Commit

Permalink
Fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ committed Oct 25, 2024
1 parent 7eabbd8 commit 3823e7d
Show file tree
Hide file tree
Showing 41 changed files with 110 additions and 1,757 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

package org.apache.dubbo.samples.tri.unary;
package org.apache.dubbo.samples.tri.unary;

import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.PathResolver;
import org.apache.dubbo.rpc.RpcException;
Expand All @@ -28,20 +28,19 @@
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.model.StubMethodDescriptor;
import org.apache.dubbo.rpc.model.StubServiceDescriptor;
import org.apache.dubbo.rpc.stub.BiStreamMethodHandler;
import org.apache.dubbo.rpc.stub.ServerStreamMethodHandler;
import org.apache.dubbo.rpc.service.Destroyable;
import org.apache.dubbo.rpc.stub.StubInvocationUtil;
import org.apache.dubbo.rpc.stub.StubInvoker;
import org.apache.dubbo.rpc.stub.StubMethodHandler;
import org.apache.dubbo.rpc.stub.StubSuppliers;
import org.apache.dubbo.rpc.stub.UnaryStubMethodHandler;

import com.google.protobuf.Message;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;

import com.google.protobuf.Message;

public final class DubboGreeterTriple {

Expand All @@ -63,31 +62,40 @@ public static Greeter newStub(Invoker<?> invoker) {
}

private static final StubMethodDescriptor greetMethod = new StubMethodDescriptor("greet",
org.apache.dubbo.samples.tri.unary.GreeterRequest.class, org.apache.dubbo.samples.tri.unary.GreeterReply.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
org.apache.dubbo.samples.tri.unary.GreeterRequest.class, org.apache.dubbo.samples.tri.unary.GreeterReply.class, MethodDescriptor.RpcType.UNARY,
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), org.apache.dubbo.samples.tri.unary.GreeterRequest::parseFrom,
org.apache.dubbo.samples.tri.unary.GreeterReply::parseFrom);

private static final StubMethodDescriptor greetAsyncMethod = new StubMethodDescriptor("greet",
org.apache.dubbo.samples.tri.unary.GreeterRequest.class, java.util.concurrent.CompletableFuture.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
org.apache.dubbo.samples.tri.unary.GreeterRequest.class, java.util.concurrent.CompletableFuture.class, MethodDescriptor.RpcType.UNARY,
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), org.apache.dubbo.samples.tri.unary.GreeterRequest::parseFrom,
org.apache.dubbo.samples.tri.unary.GreeterReply::parseFrom);

private static final StubMethodDescriptor greetProxyAsyncMethod = new StubMethodDescriptor("greetAsync",
org.apache.dubbo.samples.tri.unary.GreeterRequest.class, org.apache.dubbo.samples.tri.unary.GreeterReply.class, serviceDescriptor, MethodDescriptor.RpcType.UNARY,
org.apache.dubbo.samples.tri.unary.GreeterRequest.class, org.apache.dubbo.samples.tri.unary.GreeterReply.class, MethodDescriptor.RpcType.UNARY,
obj -> ((Message) obj).toByteArray(), obj -> ((Message) obj).toByteArray(), org.apache.dubbo.samples.tri.unary.GreeterRequest::parseFrom,
org.apache.dubbo.samples.tri.unary.GreeterReply::parseFrom);




static{
serviceDescriptor.addMethod(greetMethod);
serviceDescriptor.addMethod(greetProxyAsyncMethod);
}

public static class GreeterStub implements Greeter{
public static class GreeterStub implements Greeter, Destroyable {
private final Invoker<Greeter> invoker;

public GreeterStub(Invoker<Greeter> invoker) {
this.invoker = invoker;
}

@Override
public void $destroy() {
invoker.destroy();
}

@Override
public org.apache.dubbo.samples.tri.unary.GreeterReply greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
return StubInvocationUtil.unaryCall(invoker, greetMethod, request);
Expand All @@ -97,7 +105,6 @@ public CompletableFuture<org.apache.dubbo.samples.tri.unary.GreeterReply> greetA
return StubInvocationUtil.unaryCall(invoker, greetAsyncMethod, request);
}

@Override
public void greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request, StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply> responseObserver){
StubInvocationUtil.unaryCall(invoker, greetMethod , request, responseObserver);
}
Expand All @@ -123,15 +130,39 @@ public void accept(T t, StreamObserver<R> observer) {
};
}

@Override
public CompletableFuture<org.apache.dubbo.samples.tri.unary.GreeterReply> greetAsync(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
return CompletableFuture.completedFuture(greet(request));
}

/**
* This server stream type unary method is <b>only</b> used for generated stub to support async unary method.
* It will not be called if you are NOT using Dubbo3 generated triple stub and <b>DO NOT</b> implement this method.
*/
public void greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request, StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply> responseObserver){
greetAsync(request).whenComplete((r, t) -> {
if (t != null) {
responseObserver.onError(t);
} else {
responseObserver.onNext(r);
responseObserver.onCompleted();
}
});
}

@Override
public final Invoker<Greeter> getInvoker(URL url) {
PathResolver pathResolver = url.getOrDefaultFrameworkModel()
.getExtensionLoader(PathResolver.class)
.getDefaultExtension();
Map<String,StubMethodHandler<?, ?>> handlers = new HashMap<>();

pathResolver.addNativeStub( "/" + SERVICE_NAME + "/greet" );
pathResolver.addNativeStub( "/" + SERVICE_NAME + "/greetAsync" );
pathResolver.addNativeStub( "/" + SERVICE_NAME + "/greet");
pathResolver.addNativeStub( "/" + SERVICE_NAME + "/greetAsync");
// for compatibility
pathResolver.addNativeStub( "/" + JAVA_SERVICE_NAME + "/greet");
pathResolver.addNativeStub( "/" + JAVA_SERVICE_NAME + "/greetAsync");


BiConsumer<org.apache.dubbo.samples.tri.unary.GreeterRequest, StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply>> greetFunc = this::greet;
handlers.put(greetMethod.getMethodName(), new UnaryStubMethodHandler<>(greetFunc));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,19 @@
* limitations under the License.
*/

package org.apache.dubbo.samples.tri.unary;
package org.apache.dubbo.samples.tri.unary;

import org.apache.dubbo.common.stream.StreamObserver;
import com.google.protobuf.Message;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.concurrent.CompletableFuture;

public interface Greeter extends org.apache.dubbo.rpc.model.DubboStub {

String JAVA_SERVICE_NAME = "org.apache.dubbo.samples.tri.unary.Greeter";
String SERVICE_NAME = "org.apache.dubbo.samples.tri.unary.Greeter";

org.apache.dubbo.samples.tri.unary.GreeterReply greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request);

default CompletableFuture<org.apache.dubbo.samples.tri.unary.GreeterReply> greetAsync(org.apache.dubbo.samples.tri.unary.GreeterRequest request){
return CompletableFuture.completedFuture(greet(request));
}

/**
* This server stream type unary method is <b>only</b> used for generated stub to support async unary method.
* It will not be called if you are NOT using Dubbo3 generated triple stub and <b>DO NOT</b> implement this method.
*/
default void greet(org.apache.dubbo.samples.tri.unary.GreeterRequest request, StreamObserver<org.apache.dubbo.samples.tri.unary.GreeterReply> responseObserver){
greetAsync(request).whenComplete((r, t) -> {
if (t != null) {
responseObserver.onError(t);
} else {
responseObserver.onNext(r);
responseObserver.onCompleted();
}
});
}
CompletableFuture<org.apache.dubbo.samples.tri.unary.GreeterReply> greetAsync(org.apache.dubbo.samples.tri.unary.GreeterRequest request);





Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.apache.dubbo.springboot.demo.idl;

import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.PathResolver;
import org.apache.dubbo.rpc.RpcException;
Expand All @@ -28,20 +28,19 @@
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.model.StubMethodDescriptor;
import org.apache.dubbo.rpc.model.StubServiceDescriptor;
import org.apache.dubbo.rpc.stub.BiStreamMethodHandler;
import org.apache.dubbo.rpc.stub.ServerStreamMethodHandler;
import org.apache.dubbo.rpc.service.Destroyable;
import org.apache.dubbo.rpc.stub.StubInvocationUtil;
import org.apache.dubbo.rpc.stub.StubInvoker;
import org.apache.dubbo.rpc.stub.StubMethodHandler;
import org.apache.dubbo.rpc.stub.StubSuppliers;
import org.apache.dubbo.rpc.stub.UnaryStubMethodHandler;

import com.google.protobuf.Message;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;

import com.google.protobuf.Message;

public final class DubboGreeterTriple {

Expand Down Expand Up @@ -85,13 +84,18 @@ public static Greeter newStub(Invoker<?> invoker) {
serviceDescriptor.addMethod(greetProxyAsyncMethod);
}

public static class GreeterStub implements Greeter{
public static class GreeterStub implements Greeter, Destroyable {
private final Invoker<Greeter> invoker;

public GreeterStub(Invoker<Greeter> invoker) {
this.invoker = invoker;
}

@Override
public void $destroy() {
invoker.destroy();
}

@Override
public org.apache.dubbo.springboot.demo.idl.GreeterReply greet(org.apache.dubbo.springboot.demo.idl.GreeterRequest request){
return StubInvocationUtil.unaryCall(invoker, greetMethod, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.apache.dubbo.springboot.demo.idl;

import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.stream.StreamObserver;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.PathResolver;
import org.apache.dubbo.rpc.RpcException;
Expand All @@ -28,20 +28,19 @@
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.model.StubMethodDescriptor;
import org.apache.dubbo.rpc.model.StubServiceDescriptor;
import org.apache.dubbo.rpc.stub.BiStreamMethodHandler;
import org.apache.dubbo.rpc.stub.ServerStreamMethodHandler;
import org.apache.dubbo.rpc.service.Destroyable;
import org.apache.dubbo.rpc.stub.StubInvocationUtil;
import org.apache.dubbo.rpc.stub.StubInvoker;
import org.apache.dubbo.rpc.stub.StubMethodHandler;
import org.apache.dubbo.rpc.stub.StubSuppliers;
import org.apache.dubbo.rpc.stub.UnaryStubMethodHandler;

import com.google.protobuf.Message;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;

import com.google.protobuf.Message;

public final class DubboGreeterTriple {

Expand Down Expand Up @@ -85,13 +84,18 @@ public static Greeter newStub(Invoker<?> invoker) {
serviceDescriptor.addMethod(greetProxyAsyncMethod);
}

public static class GreeterStub implements Greeter{
public static class GreeterStub implements Greeter, Destroyable {
private final Invoker<Greeter> invoker;

public GreeterStub(Invoker<Greeter> invoker) {
this.invoker = invoker;
}

@Override
public void $destroy() {
invoker.destroy();
}

@Override
public org.apache.dubbo.springboot.demo.idl.GreeterReply greet(org.apache.dubbo.springboot.demo.idl.GreeterRequest request){
return StubInvocationUtil.unaryCall(invoker, greetMethod, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-zookeeper</artifactId>
<artifactId>dubbo-dependencies-zookeeper-curator5</artifactId>
<type>pom</type>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-observability-autoconfigure</artifactId>
<artifactId>dubbo-observability-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-tracing-otel-zipkin-starter</artifactId>
<artifactId>dubbo-tracing-otel-zipkin-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-observability-autoconfigure</artifactId>
<artifactId>dubbo-observability-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-tracing-otel-zipkin-starter</artifactId>
<artifactId>dubbo-tracing-otel-zipkin-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>

Expand Down
Loading

0 comments on commit 3823e7d

Please sign in to comment.