mirror of https://github.com/dapr/java-sdk.git
Basic Dapr HTTP Client for Actors.
This commit is contained in:
parent
900eacc5ce
commit
72388cce56
|
@ -13,6 +13,7 @@
|
|||
|
||||
# Log file
|
||||
*.log
|
||||
/syslog.txt
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
|
|
@ -7,17 +7,18 @@
|
|||
<parent>
|
||||
<groupId>io.dapr</groupId>
|
||||
<artifactId>dapr-sdk-parent</artifactId>
|
||||
<version>0.3.0-alpha</version>
|
||||
<version>0.3.0-preview01</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dapr-sdk-examples</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.3.0-alpha</version>
|
||||
<version>0.3.0-preview01</version>
|
||||
<name>dapr-sdk-examples</name>
|
||||
|
||||
<properties>
|
||||
<protobuf.output.directory>${project.build.directory}/generated-sources</protobuf.output.directory>
|
||||
<protobuf.input.directory>${project.parent.basedir}/proto</protobuf.input.directory>
|
||||
<java.version>1.11</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -61,7 +62,7 @@
|
|||
<dependency>
|
||||
<groupId>io.dapr</groupId>
|
||||
<artifactId>dapr-sdk</artifactId>
|
||||
<version>0.3.0-alpha</version>
|
||||
<version>0.3.0-preview01</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.examples.actors.http;
|
||||
|
||||
/**
|
||||
* Client that will use Actor.
|
||||
*/
|
||||
public class ActorClient {
|
||||
// TODO.
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.examples.actors.http;
|
||||
|
||||
/**
|
||||
* Example of implementation of an Actor.
|
||||
*/
|
||||
public interface DemoActor {
|
||||
// TODO.
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.examples.actors.http;
|
||||
|
||||
/**
|
||||
* Implementation of the DemoActor for the server side.
|
||||
*/
|
||||
public class DemoActorImpl {
|
||||
// TODO.
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.examples.actors.http;
|
||||
|
||||
/**
|
||||
* Service for Actor runtime.
|
||||
*/
|
||||
public class DemoActorService {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// TODO
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ import static io.dapr.examples.DaprExamplesProtos.SayResponse;
|
|||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Run in server mode:
|
||||
* dapr run --app-id hellogrpc --app-port 5000 --protocol grpc -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.invoke.grpc.HelloWorldService -Dexec.args="-p 5000"
|
||||
* dapr run --app-id hellogrpc --app-port 5000 --protocol grpc -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.invoke.grpc.HelloWorldService -Dexec.args="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5009"
|
||||
*/
|
||||
public class HelloWorldService {
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
|||
<groupId>io.dapr</groupId>
|
||||
<artifactId>dapr-sdk-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>0.3.0-alpha</version>
|
||||
<version>0.3.0-preview01</version>
|
||||
<name>dapr-sdk-parent</name>
|
||||
<description>SDK for Dapr.</description>
|
||||
<url>https://dapr.io</url>
|
||||
|
|
39
sdk/pom.xml
39
sdk/pom.xml
|
@ -7,21 +7,36 @@
|
|||
<parent>
|
||||
<groupId>io.dapr</groupId>
|
||||
<artifactId>dapr-sdk-parent</artifactId>
|
||||
<version>0.3.0-alpha</version>
|
||||
<version>0.3.0-preview01</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>dapr-sdk</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.3.0-alpha</version>
|
||||
<version>0.3.0-preview01</version>
|
||||
<name>dapr-sdk</name>
|
||||
<description>SDK for Dapr</description>
|
||||
|
||||
<properties>
|
||||
<protobuf.output.directory>generated-proto</protobuf.output.directory>
|
||||
<protobuf.output.directory>${project.build.directory}/generated-sources</protobuf.output.directory>
|
||||
<protobuf.input.directory>${project.parent.basedir}/proto</protobuf.input.directory>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.9.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<version>3.3.1.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-netty-shaded</artifactId>
|
||||
|
@ -91,11 +106,11 @@
|
|||
<outputTargets>
|
||||
<outputTarget>
|
||||
<type>java</type>
|
||||
<outputDirectory>${project.build.sourceDirectory}</outputDirectory>
|
||||
<outputDirectory>${protobuf.output.directory}</outputDirectory>
|
||||
</outputTarget>
|
||||
<outputTarget>
|
||||
<type>grpc-java</type>
|
||||
<outputDirectory>${project.build.sourceDirectory}</outputDirectory>
|
||||
<outputDirectory>${protobuf.output.directory}</outputDirectory>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}</pluginArtifact>
|
||||
</outputTarget>
|
||||
</outputTargets>
|
||||
|
@ -131,6 +146,20 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,590 +0,0 @@
|
|||
package io.dapr;
|
||||
|
||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
||||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
|
||||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
|
||||
import static io.grpc.stub.ClientCalls.futureUnaryCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* User Code definitions
|
||||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.25.0)",
|
||||
comments = "Source: daprclient.proto")
|
||||
public final class DaprClientGrpc {
|
||||
|
||||
private DaprClientGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "daprclient.DaprClient";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.InvokeEnvelope,
|
||||
com.google.protobuf.Any> getOnInvokeMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "OnInvoke",
|
||||
requestType = io.dapr.DaprClientProtos.InvokeEnvelope.class,
|
||||
responseType = com.google.protobuf.Any.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.InvokeEnvelope,
|
||||
com.google.protobuf.Any> getOnInvokeMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.InvokeEnvelope, com.google.protobuf.Any> getOnInvokeMethod;
|
||||
if ((getOnInvokeMethod = DaprClientGrpc.getOnInvokeMethod) == null) {
|
||||
synchronized (DaprClientGrpc.class) {
|
||||
if ((getOnInvokeMethod = DaprClientGrpc.getOnInvokeMethod) == null) {
|
||||
DaprClientGrpc.getOnInvokeMethod = getOnInvokeMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprClientProtos.InvokeEnvelope, com.google.protobuf.Any>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "OnInvoke"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprClientProtos.InvokeEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Any.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprClientMethodDescriptorSupplier("OnInvoke"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getOnInvokeMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<com.google.protobuf.Empty,
|
||||
io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope> getGetTopicSubscriptionsMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "GetTopicSubscriptions",
|
||||
requestType = com.google.protobuf.Empty.class,
|
||||
responseType = io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<com.google.protobuf.Empty,
|
||||
io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope> getGetTopicSubscriptionsMethod() {
|
||||
io.grpc.MethodDescriptor<com.google.protobuf.Empty, io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope> getGetTopicSubscriptionsMethod;
|
||||
if ((getGetTopicSubscriptionsMethod = DaprClientGrpc.getGetTopicSubscriptionsMethod) == null) {
|
||||
synchronized (DaprClientGrpc.class) {
|
||||
if ((getGetTopicSubscriptionsMethod = DaprClientGrpc.getGetTopicSubscriptionsMethod) == null) {
|
||||
DaprClientGrpc.getGetTopicSubscriptionsMethod = getGetTopicSubscriptionsMethod =
|
||||
io.grpc.MethodDescriptor.<com.google.protobuf.Empty, io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetTopicSubscriptions"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprClientMethodDescriptorSupplier("GetTopicSubscriptions"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getGetTopicSubscriptionsMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<com.google.protobuf.Empty,
|
||||
io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope> getGetBindingsSubscriptionsMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "GetBindingsSubscriptions",
|
||||
requestType = com.google.protobuf.Empty.class,
|
||||
responseType = io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<com.google.protobuf.Empty,
|
||||
io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope> getGetBindingsSubscriptionsMethod() {
|
||||
io.grpc.MethodDescriptor<com.google.protobuf.Empty, io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope> getGetBindingsSubscriptionsMethod;
|
||||
if ((getGetBindingsSubscriptionsMethod = DaprClientGrpc.getGetBindingsSubscriptionsMethod) == null) {
|
||||
synchronized (DaprClientGrpc.class) {
|
||||
if ((getGetBindingsSubscriptionsMethod = DaprClientGrpc.getGetBindingsSubscriptionsMethod) == null) {
|
||||
DaprClientGrpc.getGetBindingsSubscriptionsMethod = getGetBindingsSubscriptionsMethod =
|
||||
io.grpc.MethodDescriptor.<com.google.protobuf.Empty, io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetBindingsSubscriptions"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprClientMethodDescriptorSupplier("GetBindingsSubscriptions"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getGetBindingsSubscriptionsMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.BindingEventEnvelope,
|
||||
io.dapr.DaprClientProtos.BindingResponseEnvelope> getOnBindingEventMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "OnBindingEvent",
|
||||
requestType = io.dapr.DaprClientProtos.BindingEventEnvelope.class,
|
||||
responseType = io.dapr.DaprClientProtos.BindingResponseEnvelope.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.BindingEventEnvelope,
|
||||
io.dapr.DaprClientProtos.BindingResponseEnvelope> getOnBindingEventMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.BindingEventEnvelope, io.dapr.DaprClientProtos.BindingResponseEnvelope> getOnBindingEventMethod;
|
||||
if ((getOnBindingEventMethod = DaprClientGrpc.getOnBindingEventMethod) == null) {
|
||||
synchronized (DaprClientGrpc.class) {
|
||||
if ((getOnBindingEventMethod = DaprClientGrpc.getOnBindingEventMethod) == null) {
|
||||
DaprClientGrpc.getOnBindingEventMethod = getOnBindingEventMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprClientProtos.BindingEventEnvelope, io.dapr.DaprClientProtos.BindingResponseEnvelope>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "OnBindingEvent"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprClientProtos.BindingEventEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprClientProtos.BindingResponseEnvelope.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprClientMethodDescriptorSupplier("OnBindingEvent"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getOnBindingEventMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.CloudEventEnvelope,
|
||||
com.google.protobuf.Empty> getOnTopicEventMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "OnTopicEvent",
|
||||
requestType = io.dapr.DaprClientProtos.CloudEventEnvelope.class,
|
||||
responseType = com.google.protobuf.Empty.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.CloudEventEnvelope,
|
||||
com.google.protobuf.Empty> getOnTopicEventMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprClientProtos.CloudEventEnvelope, com.google.protobuf.Empty> getOnTopicEventMethod;
|
||||
if ((getOnTopicEventMethod = DaprClientGrpc.getOnTopicEventMethod) == null) {
|
||||
synchronized (DaprClientGrpc.class) {
|
||||
if ((getOnTopicEventMethod = DaprClientGrpc.getOnTopicEventMethod) == null) {
|
||||
DaprClientGrpc.getOnTopicEventMethod = getOnTopicEventMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprClientProtos.CloudEventEnvelope, com.google.protobuf.Empty>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "OnTopicEvent"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprClientProtos.CloudEventEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprClientMethodDescriptorSupplier("OnTopicEvent"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getOnTopicEventMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new async stub that supports all call types for the service
|
||||
*/
|
||||
public static DaprClientStub newStub(io.grpc.Channel channel) {
|
||||
return new DaprClientStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
||||
*/
|
||||
public static DaprClientBlockingStub newBlockingStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new DaprClientBlockingStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
||||
*/
|
||||
public static DaprClientFutureStub newFutureStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new DaprClientFutureStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* User Code definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static abstract class DaprClientImplBase implements io.grpc.BindableService {
|
||||
|
||||
/**
|
||||
*/
|
||||
public void onInvoke(io.dapr.DaprClientProtos.InvokeEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Any> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getOnInvokeMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void getTopicSubscriptions(com.google.protobuf.Empty request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getGetTopicSubscriptionsMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void getBindingsSubscriptions(com.google.protobuf.Empty request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getGetBindingsSubscriptionsMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void onBindingEvent(io.dapr.DaprClientProtos.BindingEventEnvelope request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.BindingResponseEnvelope> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getOnBindingEventMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void onTopicEvent(io.dapr.DaprClientProtos.CloudEventEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getOnTopicEventMethod(), responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
getOnInvokeMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprClientProtos.InvokeEnvelope,
|
||||
com.google.protobuf.Any>(
|
||||
this, METHODID_ON_INVOKE)))
|
||||
.addMethod(
|
||||
getGetTopicSubscriptionsMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
com.google.protobuf.Empty,
|
||||
io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope>(
|
||||
this, METHODID_GET_TOPIC_SUBSCRIPTIONS)))
|
||||
.addMethod(
|
||||
getGetBindingsSubscriptionsMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
com.google.protobuf.Empty,
|
||||
io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope>(
|
||||
this, METHODID_GET_BINDINGS_SUBSCRIPTIONS)))
|
||||
.addMethod(
|
||||
getOnBindingEventMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprClientProtos.BindingEventEnvelope,
|
||||
io.dapr.DaprClientProtos.BindingResponseEnvelope>(
|
||||
this, METHODID_ON_BINDING_EVENT)))
|
||||
.addMethod(
|
||||
getOnTopicEventMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprClientProtos.CloudEventEnvelope,
|
||||
com.google.protobuf.Empty>(
|
||||
this, METHODID_ON_TOPIC_EVENT)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* User Code definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static final class DaprClientStub extends io.grpc.stub.AbstractStub<DaprClientStub> {
|
||||
private DaprClientStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private DaprClientStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected DaprClientStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new DaprClientStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void onInvoke(io.dapr.DaprClientProtos.InvokeEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Any> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getOnInvokeMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void getTopicSubscriptions(com.google.protobuf.Empty request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getGetTopicSubscriptionsMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void getBindingsSubscriptions(com.google.protobuf.Empty request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getGetBindingsSubscriptionsMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void onBindingEvent(io.dapr.DaprClientProtos.BindingEventEnvelope request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.BindingResponseEnvelope> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getOnBindingEventMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void onTopicEvent(io.dapr.DaprClientProtos.CloudEventEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getOnTopicEventMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* User Code definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static final class DaprClientBlockingStub extends io.grpc.stub.AbstractStub<DaprClientBlockingStub> {
|
||||
private DaprClientBlockingStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private DaprClientBlockingStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected DaprClientBlockingStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new DaprClientBlockingStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.protobuf.Any onInvoke(io.dapr.DaprClientProtos.InvokeEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getOnInvokeMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope getTopicSubscriptions(com.google.protobuf.Empty request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getGetTopicSubscriptionsMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope getBindingsSubscriptions(com.google.protobuf.Empty request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getGetBindingsSubscriptionsMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.dapr.DaprClientProtos.BindingResponseEnvelope onBindingEvent(io.dapr.DaprClientProtos.BindingEventEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getOnBindingEventMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.protobuf.Empty onTopicEvent(io.dapr.DaprClientProtos.CloudEventEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getOnTopicEventMethod(), getCallOptions(), request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* User Code definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static final class DaprClientFutureStub extends io.grpc.stub.AbstractStub<DaprClientFutureStub> {
|
||||
private DaprClientFutureStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private DaprClientFutureStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected DaprClientFutureStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new DaprClientFutureStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Any> onInvoke(
|
||||
io.dapr.DaprClientProtos.InvokeEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getOnInvokeMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope> getTopicSubscriptions(
|
||||
com.google.protobuf.Empty request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getGetTopicSubscriptionsMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope> getBindingsSubscriptions(
|
||||
com.google.protobuf.Empty request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getGetBindingsSubscriptionsMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<io.dapr.DaprClientProtos.BindingResponseEnvelope> onBindingEvent(
|
||||
io.dapr.DaprClientProtos.BindingEventEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getOnBindingEventMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Empty> onTopicEvent(
|
||||
io.dapr.DaprClientProtos.CloudEventEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getOnTopicEventMethod(), getCallOptions()), request);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int METHODID_ON_INVOKE = 0;
|
||||
private static final int METHODID_GET_TOPIC_SUBSCRIPTIONS = 1;
|
||||
private static final int METHODID_GET_BINDINGS_SUBSCRIPTIONS = 2;
|
||||
private static final int METHODID_ON_BINDING_EVENT = 3;
|
||||
private static final int METHODID_ON_TOPIC_EVENT = 4;
|
||||
|
||||
private static final class MethodHandlers<Req, Resp> implements
|
||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
||||
private final DaprClientImplBase serviceImpl;
|
||||
private final int methodId;
|
||||
|
||||
MethodHandlers(DaprClientImplBase serviceImpl, int methodId) {
|
||||
this.serviceImpl = serviceImpl;
|
||||
this.methodId = methodId;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
case METHODID_ON_INVOKE:
|
||||
serviceImpl.onInvoke((io.dapr.DaprClientProtos.InvokeEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<com.google.protobuf.Any>) responseObserver);
|
||||
break;
|
||||
case METHODID_GET_TOPIC_SUBSCRIPTIONS:
|
||||
serviceImpl.getTopicSubscriptions((com.google.protobuf.Empty) request,
|
||||
(io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.GetTopicSubscriptionsEnvelope>) responseObserver);
|
||||
break;
|
||||
case METHODID_GET_BINDINGS_SUBSCRIPTIONS:
|
||||
serviceImpl.getBindingsSubscriptions((com.google.protobuf.Empty) request,
|
||||
(io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.GetBindingsSubscriptionsEnvelope>) responseObserver);
|
||||
break;
|
||||
case METHODID_ON_BINDING_EVENT:
|
||||
serviceImpl.onBindingEvent((io.dapr.DaprClientProtos.BindingEventEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<io.dapr.DaprClientProtos.BindingResponseEnvelope>) responseObserver);
|
||||
break;
|
||||
case METHODID_ON_TOPIC_EVENT:
|
||||
serviceImpl.onTopicEvent((io.dapr.DaprClientProtos.CloudEventEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<com.google.protobuf.Empty>) responseObserver);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class DaprClientBaseDescriptorSupplier
|
||||
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
|
||||
DaprClientBaseDescriptorSupplier() {}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
|
||||
return io.dapr.DaprClientProtos.getDescriptor();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
|
||||
return getFileDescriptor().findServiceByName("DaprClient");
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DaprClientFileDescriptorSupplier
|
||||
extends DaprClientBaseDescriptorSupplier {
|
||||
DaprClientFileDescriptorSupplier() {}
|
||||
}
|
||||
|
||||
private static final class DaprClientMethodDescriptorSupplier
|
||||
extends DaprClientBaseDescriptorSupplier
|
||||
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
|
||||
private final String methodName;
|
||||
|
||||
DaprClientMethodDescriptorSupplier(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
|
||||
return getServiceDescriptor().findMethodByName(methodName);
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
||||
|
||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
synchronized (DaprClientGrpc.class) {
|
||||
result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
||||
.setSchemaDescriptor(new DaprClientFileDescriptorSupplier())
|
||||
.addMethod(getOnInvokeMethod())
|
||||
.addMethod(getGetTopicSubscriptionsMethod())
|
||||
.addMethod(getGetBindingsSubscriptionsMethod())
|
||||
.addMethod(getOnBindingEventMethod())
|
||||
.addMethod(getOnTopicEventMethod())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,664 +0,0 @@
|
|||
package io.dapr;
|
||||
|
||||
import static io.grpc.MethodDescriptor.generateFullMethodName;
|
||||
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
|
||||
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
|
||||
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
|
||||
import static io.grpc.stub.ClientCalls.futureUnaryCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
|
||||
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Dapr definitions
|
||||
* </pre>
|
||||
*/
|
||||
@javax.annotation.Generated(
|
||||
value = "by gRPC proto compiler (version 1.25.0)",
|
||||
comments = "Source: dapr.proto")
|
||||
public final class DaprGrpc {
|
||||
|
||||
private DaprGrpc() {}
|
||||
|
||||
public static final String SERVICE_NAME = "dapr.Dapr";
|
||||
|
||||
// Static method descriptors that strictly reflect the proto.
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprProtos.PublishEventEnvelope,
|
||||
com.google.protobuf.Empty> getPublishEventMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "PublishEvent",
|
||||
requestType = io.dapr.DaprProtos.PublishEventEnvelope.class,
|
||||
responseType = com.google.protobuf.Empty.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprProtos.PublishEventEnvelope,
|
||||
com.google.protobuf.Empty> getPublishEventMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprProtos.PublishEventEnvelope, com.google.protobuf.Empty> getPublishEventMethod;
|
||||
if ((getPublishEventMethod = DaprGrpc.getPublishEventMethod) == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
if ((getPublishEventMethod = DaprGrpc.getPublishEventMethod) == null) {
|
||||
DaprGrpc.getPublishEventMethod = getPublishEventMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprProtos.PublishEventEnvelope, com.google.protobuf.Empty>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "PublishEvent"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.PublishEventEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprMethodDescriptorSupplier("PublishEvent"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getPublishEventMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprProtos.InvokeServiceEnvelope,
|
||||
io.dapr.DaprProtos.InvokeServiceResponseEnvelope> getInvokeServiceMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "InvokeService",
|
||||
requestType = io.dapr.DaprProtos.InvokeServiceEnvelope.class,
|
||||
responseType = io.dapr.DaprProtos.InvokeServiceResponseEnvelope.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprProtos.InvokeServiceEnvelope,
|
||||
io.dapr.DaprProtos.InvokeServiceResponseEnvelope> getInvokeServiceMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprProtos.InvokeServiceEnvelope, io.dapr.DaprProtos.InvokeServiceResponseEnvelope> getInvokeServiceMethod;
|
||||
if ((getInvokeServiceMethod = DaprGrpc.getInvokeServiceMethod) == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
if ((getInvokeServiceMethod = DaprGrpc.getInvokeServiceMethod) == null) {
|
||||
DaprGrpc.getInvokeServiceMethod = getInvokeServiceMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprProtos.InvokeServiceEnvelope, io.dapr.DaprProtos.InvokeServiceResponseEnvelope>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "InvokeService"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.InvokeServiceEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.InvokeServiceResponseEnvelope.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprMethodDescriptorSupplier("InvokeService"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getInvokeServiceMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprProtos.InvokeBindingEnvelope,
|
||||
com.google.protobuf.Empty> getInvokeBindingMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "InvokeBinding",
|
||||
requestType = io.dapr.DaprProtos.InvokeBindingEnvelope.class,
|
||||
responseType = com.google.protobuf.Empty.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprProtos.InvokeBindingEnvelope,
|
||||
com.google.protobuf.Empty> getInvokeBindingMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprProtos.InvokeBindingEnvelope, com.google.protobuf.Empty> getInvokeBindingMethod;
|
||||
if ((getInvokeBindingMethod = DaprGrpc.getInvokeBindingMethod) == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
if ((getInvokeBindingMethod = DaprGrpc.getInvokeBindingMethod) == null) {
|
||||
DaprGrpc.getInvokeBindingMethod = getInvokeBindingMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprProtos.InvokeBindingEnvelope, com.google.protobuf.Empty>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "InvokeBinding"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.InvokeBindingEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprMethodDescriptorSupplier("InvokeBinding"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getInvokeBindingMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprProtos.GetStateEnvelope,
|
||||
io.dapr.DaprProtos.GetStateResponseEnvelope> getGetStateMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "GetState",
|
||||
requestType = io.dapr.DaprProtos.GetStateEnvelope.class,
|
||||
responseType = io.dapr.DaprProtos.GetStateResponseEnvelope.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprProtos.GetStateEnvelope,
|
||||
io.dapr.DaprProtos.GetStateResponseEnvelope> getGetStateMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprProtos.GetStateEnvelope, io.dapr.DaprProtos.GetStateResponseEnvelope> getGetStateMethod;
|
||||
if ((getGetStateMethod = DaprGrpc.getGetStateMethod) == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
if ((getGetStateMethod = DaprGrpc.getGetStateMethod) == null) {
|
||||
DaprGrpc.getGetStateMethod = getGetStateMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprProtos.GetStateEnvelope, io.dapr.DaprProtos.GetStateResponseEnvelope>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetState"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.GetStateEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.GetStateResponseEnvelope.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprMethodDescriptorSupplier("GetState"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getGetStateMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprProtos.SaveStateEnvelope,
|
||||
com.google.protobuf.Empty> getSaveStateMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "SaveState",
|
||||
requestType = io.dapr.DaprProtos.SaveStateEnvelope.class,
|
||||
responseType = com.google.protobuf.Empty.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprProtos.SaveStateEnvelope,
|
||||
com.google.protobuf.Empty> getSaveStateMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprProtos.SaveStateEnvelope, com.google.protobuf.Empty> getSaveStateMethod;
|
||||
if ((getSaveStateMethod = DaprGrpc.getSaveStateMethod) == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
if ((getSaveStateMethod = DaprGrpc.getSaveStateMethod) == null) {
|
||||
DaprGrpc.getSaveStateMethod = getSaveStateMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprProtos.SaveStateEnvelope, com.google.protobuf.Empty>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "SaveState"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.SaveStateEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprMethodDescriptorSupplier("SaveState"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getSaveStateMethod;
|
||||
}
|
||||
|
||||
private static volatile io.grpc.MethodDescriptor<io.dapr.DaprProtos.DeleteStateEnvelope,
|
||||
com.google.protobuf.Empty> getDeleteStateMethod;
|
||||
|
||||
@io.grpc.stub.annotations.RpcMethod(
|
||||
fullMethodName = SERVICE_NAME + '/' + "DeleteState",
|
||||
requestType = io.dapr.DaprProtos.DeleteStateEnvelope.class,
|
||||
responseType = com.google.protobuf.Empty.class,
|
||||
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
public static io.grpc.MethodDescriptor<io.dapr.DaprProtos.DeleteStateEnvelope,
|
||||
com.google.protobuf.Empty> getDeleteStateMethod() {
|
||||
io.grpc.MethodDescriptor<io.dapr.DaprProtos.DeleteStateEnvelope, com.google.protobuf.Empty> getDeleteStateMethod;
|
||||
if ((getDeleteStateMethod = DaprGrpc.getDeleteStateMethod) == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
if ((getDeleteStateMethod = DaprGrpc.getDeleteStateMethod) == null) {
|
||||
DaprGrpc.getDeleteStateMethod = getDeleteStateMethod =
|
||||
io.grpc.MethodDescriptor.<io.dapr.DaprProtos.DeleteStateEnvelope, com.google.protobuf.Empty>newBuilder()
|
||||
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
|
||||
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteState"))
|
||||
.setSampledToLocalTracing(true)
|
||||
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
io.dapr.DaprProtos.DeleteStateEnvelope.getDefaultInstance()))
|
||||
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
|
||||
com.google.protobuf.Empty.getDefaultInstance()))
|
||||
.setSchemaDescriptor(new DaprMethodDescriptorSupplier("DeleteState"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return getDeleteStateMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new async stub that supports all call types for the service
|
||||
*/
|
||||
public static DaprStub newStub(io.grpc.Channel channel) {
|
||||
return new DaprStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
|
||||
*/
|
||||
public static DaprBlockingStub newBlockingStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new DaprBlockingStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ListenableFuture-style stub that supports unary calls on the service
|
||||
*/
|
||||
public static DaprFutureStub newFutureStub(
|
||||
io.grpc.Channel channel) {
|
||||
return new DaprFutureStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Dapr definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static abstract class DaprImplBase implements io.grpc.BindableService {
|
||||
|
||||
/**
|
||||
*/
|
||||
public void publishEvent(io.dapr.DaprProtos.PublishEventEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getPublishEventMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void invokeService(io.dapr.DaprProtos.InvokeServiceEnvelope request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprProtos.InvokeServiceResponseEnvelope> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getInvokeServiceMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void invokeBinding(io.dapr.DaprProtos.InvokeBindingEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getInvokeBindingMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void getState(io.dapr.DaprProtos.GetStateEnvelope request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprProtos.GetStateResponseEnvelope> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getGetStateMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void saveState(io.dapr.DaprProtos.SaveStateEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getSaveStateMethod(), responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void deleteState(io.dapr.DaprProtos.DeleteStateEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnimplementedUnaryCall(getDeleteStateMethod(), responseObserver);
|
||||
}
|
||||
|
||||
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
|
||||
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
|
||||
.addMethod(
|
||||
getPublishEventMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprProtos.PublishEventEnvelope,
|
||||
com.google.protobuf.Empty>(
|
||||
this, METHODID_PUBLISH_EVENT)))
|
||||
.addMethod(
|
||||
getInvokeServiceMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprProtos.InvokeServiceEnvelope,
|
||||
io.dapr.DaprProtos.InvokeServiceResponseEnvelope>(
|
||||
this, METHODID_INVOKE_SERVICE)))
|
||||
.addMethod(
|
||||
getInvokeBindingMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprProtos.InvokeBindingEnvelope,
|
||||
com.google.protobuf.Empty>(
|
||||
this, METHODID_INVOKE_BINDING)))
|
||||
.addMethod(
|
||||
getGetStateMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprProtos.GetStateEnvelope,
|
||||
io.dapr.DaprProtos.GetStateResponseEnvelope>(
|
||||
this, METHODID_GET_STATE)))
|
||||
.addMethod(
|
||||
getSaveStateMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprProtos.SaveStateEnvelope,
|
||||
com.google.protobuf.Empty>(
|
||||
this, METHODID_SAVE_STATE)))
|
||||
.addMethod(
|
||||
getDeleteStateMethod(),
|
||||
asyncUnaryCall(
|
||||
new MethodHandlers<
|
||||
io.dapr.DaprProtos.DeleteStateEnvelope,
|
||||
com.google.protobuf.Empty>(
|
||||
this, METHODID_DELETE_STATE)))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Dapr definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static final class DaprStub extends io.grpc.stub.AbstractStub<DaprStub> {
|
||||
private DaprStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private DaprStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected DaprStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new DaprStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void publishEvent(io.dapr.DaprProtos.PublishEventEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getPublishEventMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void invokeService(io.dapr.DaprProtos.InvokeServiceEnvelope request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprProtos.InvokeServiceResponseEnvelope> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getInvokeServiceMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void invokeBinding(io.dapr.DaprProtos.InvokeBindingEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getInvokeBindingMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void getState(io.dapr.DaprProtos.GetStateEnvelope request,
|
||||
io.grpc.stub.StreamObserver<io.dapr.DaprProtos.GetStateResponseEnvelope> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getGetStateMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void saveState(io.dapr.DaprProtos.SaveStateEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getSaveStateMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public void deleteState(io.dapr.DaprProtos.DeleteStateEnvelope request,
|
||||
io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) {
|
||||
asyncUnaryCall(
|
||||
getChannel().newCall(getDeleteStateMethod(), getCallOptions()), request, responseObserver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Dapr definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static final class DaprBlockingStub extends io.grpc.stub.AbstractStub<DaprBlockingStub> {
|
||||
private DaprBlockingStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private DaprBlockingStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected DaprBlockingStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new DaprBlockingStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.protobuf.Empty publishEvent(io.dapr.DaprProtos.PublishEventEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getPublishEventMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.dapr.DaprProtos.InvokeServiceResponseEnvelope invokeService(io.dapr.DaprProtos.InvokeServiceEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getInvokeServiceMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.protobuf.Empty invokeBinding(io.dapr.DaprProtos.InvokeBindingEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getInvokeBindingMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public io.dapr.DaprProtos.GetStateResponseEnvelope getState(io.dapr.DaprProtos.GetStateEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getGetStateMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.protobuf.Empty saveState(io.dapr.DaprProtos.SaveStateEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getSaveStateMethod(), getCallOptions(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.protobuf.Empty deleteState(io.dapr.DaprProtos.DeleteStateEnvelope request) {
|
||||
return blockingUnaryCall(
|
||||
getChannel(), getDeleteStateMethod(), getCallOptions(), request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Dapr definitions
|
||||
* </pre>
|
||||
*/
|
||||
public static final class DaprFutureStub extends io.grpc.stub.AbstractStub<DaprFutureStub> {
|
||||
private DaprFutureStub(io.grpc.Channel channel) {
|
||||
super(channel);
|
||||
}
|
||||
|
||||
private DaprFutureStub(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
super(channel, callOptions);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected DaprFutureStub build(io.grpc.Channel channel,
|
||||
io.grpc.CallOptions callOptions) {
|
||||
return new DaprFutureStub(channel, callOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Empty> publishEvent(
|
||||
io.dapr.DaprProtos.PublishEventEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getPublishEventMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<io.dapr.DaprProtos.InvokeServiceResponseEnvelope> invokeService(
|
||||
io.dapr.DaprProtos.InvokeServiceEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getInvokeServiceMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Empty> invokeBinding(
|
||||
io.dapr.DaprProtos.InvokeBindingEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getInvokeBindingMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<io.dapr.DaprProtos.GetStateResponseEnvelope> getState(
|
||||
io.dapr.DaprProtos.GetStateEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getGetStateMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Empty> saveState(
|
||||
io.dapr.DaprProtos.SaveStateEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getSaveStateMethod(), getCallOptions()), request);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public com.google.common.util.concurrent.ListenableFuture<com.google.protobuf.Empty> deleteState(
|
||||
io.dapr.DaprProtos.DeleteStateEnvelope request) {
|
||||
return futureUnaryCall(
|
||||
getChannel().newCall(getDeleteStateMethod(), getCallOptions()), request);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int METHODID_PUBLISH_EVENT = 0;
|
||||
private static final int METHODID_INVOKE_SERVICE = 1;
|
||||
private static final int METHODID_INVOKE_BINDING = 2;
|
||||
private static final int METHODID_GET_STATE = 3;
|
||||
private static final int METHODID_SAVE_STATE = 4;
|
||||
private static final int METHODID_DELETE_STATE = 5;
|
||||
|
||||
private static final class MethodHandlers<Req, Resp> implements
|
||||
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
|
||||
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
|
||||
private final DaprImplBase serviceImpl;
|
||||
private final int methodId;
|
||||
|
||||
MethodHandlers(DaprImplBase serviceImpl, int methodId) {
|
||||
this.serviceImpl = serviceImpl;
|
||||
this.methodId = methodId;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
case METHODID_PUBLISH_EVENT:
|
||||
serviceImpl.publishEvent((io.dapr.DaprProtos.PublishEventEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<com.google.protobuf.Empty>) responseObserver);
|
||||
break;
|
||||
case METHODID_INVOKE_SERVICE:
|
||||
serviceImpl.invokeService((io.dapr.DaprProtos.InvokeServiceEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<io.dapr.DaprProtos.InvokeServiceResponseEnvelope>) responseObserver);
|
||||
break;
|
||||
case METHODID_INVOKE_BINDING:
|
||||
serviceImpl.invokeBinding((io.dapr.DaprProtos.InvokeBindingEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<com.google.protobuf.Empty>) responseObserver);
|
||||
break;
|
||||
case METHODID_GET_STATE:
|
||||
serviceImpl.getState((io.dapr.DaprProtos.GetStateEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<io.dapr.DaprProtos.GetStateResponseEnvelope>) responseObserver);
|
||||
break;
|
||||
case METHODID_SAVE_STATE:
|
||||
serviceImpl.saveState((io.dapr.DaprProtos.SaveStateEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<com.google.protobuf.Empty>) responseObserver);
|
||||
break;
|
||||
case METHODID_DELETE_STATE:
|
||||
serviceImpl.deleteState((io.dapr.DaprProtos.DeleteStateEnvelope) request,
|
||||
(io.grpc.stub.StreamObserver<com.google.protobuf.Empty>) responseObserver);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("unchecked")
|
||||
public io.grpc.stub.StreamObserver<Req> invoke(
|
||||
io.grpc.stub.StreamObserver<Resp> responseObserver) {
|
||||
switch (methodId) {
|
||||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class DaprBaseDescriptorSupplier
|
||||
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
|
||||
DaprBaseDescriptorSupplier() {}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
|
||||
return io.dapr.DaprProtos.getDescriptor();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
|
||||
return getFileDescriptor().findServiceByName("Dapr");
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DaprFileDescriptorSupplier
|
||||
extends DaprBaseDescriptorSupplier {
|
||||
DaprFileDescriptorSupplier() {}
|
||||
}
|
||||
|
||||
private static final class DaprMethodDescriptorSupplier
|
||||
extends DaprBaseDescriptorSupplier
|
||||
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
|
||||
private final String methodName;
|
||||
|
||||
DaprMethodDescriptorSupplier(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
|
||||
return getServiceDescriptor().findMethodByName(methodName);
|
||||
}
|
||||
}
|
||||
|
||||
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
|
||||
|
||||
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
|
||||
io.grpc.ServiceDescriptor result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
synchronized (DaprGrpc.class) {
|
||||
result = serviceDescriptor;
|
||||
if (result == null) {
|
||||
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
|
||||
.setSchemaDescriptor(new DaprFileDescriptorSupplier())
|
||||
.addMethod(getPublishEventMethod())
|
||||
.addMethod(getInvokeServiceMethod())
|
||||
.addMethod(getInvokeBindingMethod())
|
||||
.addMethod(getGetStateMethod())
|
||||
.addMethod(getSaveStateMethod())
|
||||
.addMethod(getDeleteStateMethod())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
/**
|
||||
* Useful constants for the Dapr's Actor SDK.
|
||||
*/
|
||||
final class Constants {
|
||||
|
||||
/**
|
||||
* Dapr API used in this client.
|
||||
*/
|
||||
public static final String API_VERSION = "v1.0";
|
||||
|
||||
/**
|
||||
* Dapr's default hostname.
|
||||
*/
|
||||
public static final String DEFAULT_HOSTNAME = "localhost";
|
||||
|
||||
/**
|
||||
* Dapr's default port.
|
||||
*/
|
||||
public static final int DEFAULT_PORT = 3500;
|
||||
|
||||
/**
|
||||
* Environment variable used to set Dapr's port.
|
||||
*/
|
||||
public static final String ENV_DAPR_HTTP_PORT = "DAPR_HTTP_PORT";
|
||||
|
||||
/**
|
||||
* Header used for request id in Dapr.
|
||||
*/
|
||||
public static final String HEADER_DAPR_REQUEST_ID = "X-DaprRequestId";
|
||||
|
||||
/**
|
||||
* Base URL for Dapr Actor APIs.
|
||||
*/
|
||||
private static String ACTORS_BASE_URL = API_VERSION + "/" + "actors";
|
||||
|
||||
/**
|
||||
* String format for Actors state management relative url.
|
||||
*/
|
||||
public static String ACTOR_STATE_KEY_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/state/%s";
|
||||
|
||||
/**
|
||||
* String format for Actors state management relative url.
|
||||
*/
|
||||
public static String ACTOR_STATE_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/state";
|
||||
|
||||
/**
|
||||
* String format for Actors method invocation relative url.
|
||||
*/
|
||||
public static String ACTOR_METHOD_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/method/%s";
|
||||
|
||||
/**
|
||||
* String format for Actors reminder registration relative url..
|
||||
*/
|
||||
public static String ACTOR_REMINDER_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/reminders/%s";
|
||||
|
||||
/**
|
||||
* String format for Actors timer registration relative url..
|
||||
*/
|
||||
public static String ACTOR_TIMER_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/reminders/%s";
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Interface for interacting with Dapr runtime.
|
||||
*/
|
||||
interface DaprAsyncClient {
|
||||
|
||||
/**
|
||||
* Invokes an Actor method on Dapr.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param methodName Method name to invoke.
|
||||
* @param jsonPayload Serialized body.
|
||||
* @return Asynchronous result with the Actor's response.
|
||||
*/
|
||||
Mono<String> invokeActorMethod(String actorType, String actorId, String methodName, String jsonPayload);
|
||||
|
||||
/**
|
||||
* Gets a state from Dapr's Actor.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param keyName State name.
|
||||
* @return Asynchronous result with current state value.
|
||||
*/
|
||||
Mono<String> getState(String actorType, String actorId, String keyName);
|
||||
|
||||
/**
|
||||
* Removes Actor state in Dapr. This is temporary until the Dapr runtime implements the Batch state update.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param keyName State name.
|
||||
* @return Asynchronous void result.
|
||||
*/
|
||||
Mono<Void> removeState(String actorType, String actorId, String keyName);
|
||||
|
||||
/**
|
||||
* Saves state batch to Dapr.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param data State to be saved.
|
||||
* @return Asynchronous void result.
|
||||
*/
|
||||
Mono<Void> saveStateTransactionally(String actorType, String actorId, String data);
|
||||
|
||||
/**
|
||||
* Register a reminder.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param reminderName Name of reminder to be registered.
|
||||
* @param data JSON reminder data as per Dapr's spec.
|
||||
* @return Asynchronous void result.
|
||||
*/
|
||||
Mono<Void> registerReminder(String actorType, String actorId, String reminderName, String data);
|
||||
|
||||
/**
|
||||
* Unregisters a reminder.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param reminderName Name of reminder to be unregistered.
|
||||
* @return Asynchronous void result.
|
||||
*/
|
||||
Mono<Void> unregisterReminder(String actorType, String actorId, String reminderName);
|
||||
|
||||
/**
|
||||
* Registers a timer.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param timerName Name of timer to be registered.
|
||||
* @param data JSON reminder data as per Dapr's spec.
|
||||
* @return Asynchronous void result.
|
||||
*/
|
||||
Mono<Void> registerTimer(String actorType, String actorId, String timerName, String data);
|
||||
|
||||
/**
|
||||
* Unregisters a timer.
|
||||
* @param actorType Type of actor.
|
||||
* @param actorId Actor Identifier.
|
||||
* @param timerName Name of timer to be unregistered.
|
||||
* @return Asynchronous void result.
|
||||
*/
|
||||
Mono<Void> unregisterTimerAsync(String actorType, String actorId, String timerName);
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
/**
|
||||
* Builds an instance of DaprAsyncClient or DaprClient.
|
||||
*/
|
||||
class DaprClientBuilder {
|
||||
|
||||
/**
|
||||
* Default hostname for Dapr.
|
||||
*/
|
||||
private String hostname = Constants.DEFAULT_HOSTNAME;
|
||||
|
||||
/**
|
||||
* Default port for Dapr after checking environment variable.
|
||||
*/
|
||||
private int port = DaprClientBuilder.GetEnvPortOrDefault();
|
||||
|
||||
/**
|
||||
* Builds an async client.
|
||||
* @return Builds an async client.
|
||||
*/
|
||||
public DaprAsyncClient buildAsyncClient() {
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
// TODO: Expose configurations for OkHttpClient or com.microsoft.rest.RestClient.
|
||||
String baseUrl = String.format("http://%s:%d/", this.hostname, this.port);
|
||||
return new DaprHttpAsyncClient(baseUrl, builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the hostname.
|
||||
* @param hostname new hostname.
|
||||
* @return This instance.
|
||||
*/
|
||||
public DaprClientBuilder withHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the port.
|
||||
* @param port New port.
|
||||
* @return This instance.
|
||||
*/
|
||||
public DaprClientBuilder withPort(int port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to get a valid port from environment variable or returns default.
|
||||
* @return Port defined in env variable or default.
|
||||
*/
|
||||
private static int GetEnvPortOrDefault() {
|
||||
String envPort = System.getenv(Constants.ENV_DAPR_HTTP_PORT);
|
||||
if (envPort == null) {
|
||||
return Constants.DEFAULT_PORT;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(envPort.trim());
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Constants.DEFAULT_PORT;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
/**
|
||||
* Represents an error message from Dapr.
|
||||
*/
|
||||
class DaprError {
|
||||
|
||||
/**
|
||||
* Error code.
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* Error Message.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Gets the error code.
|
||||
* @return Error code.
|
||||
*/
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error code.
|
||||
* @param errorCode Error code.
|
||||
* @return This instance.
|
||||
*/
|
||||
public DaprError setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the error message.
|
||||
* @return Error message.
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error message.
|
||||
* @param message Error message.
|
||||
* @return This instance.
|
||||
*/
|
||||
public DaprError setMessage(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A Dapr's specific exception.
|
||||
*/
|
||||
class DaprException extends IOException {
|
||||
|
||||
/**
|
||||
* Dapr's error code for this exception.
|
||||
*/
|
||||
private String errorCode;
|
||||
|
||||
/**
|
||||
* New exception from a server-side generated error code and message.
|
||||
* @param daprError Server-side error.
|
||||
*/
|
||||
DaprException(DaprError daprError) {
|
||||
this(daprError.getErrorCode(), daprError.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* New Exception from a client-side generated error code and message.
|
||||
* @param errorCode Client-side error code.
|
||||
* @param message Client-side error message.
|
||||
*/
|
||||
DaprException(String errorCode, String message) {
|
||||
super(String.format("%s: %s", errorCode, message));
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception's error code.
|
||||
* @return Error code.
|
||||
*/
|
||||
String getErrorCode() {
|
||||
return this.errorCode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import okhttp3.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Http client to call Dapr's API for actors.
|
||||
*/
|
||||
class DaprHttpAsyncClient implements DaprAsyncClient {
|
||||
|
||||
/**
|
||||
* Defines the standard application/json type for HTTP calls in Dapr.
|
||||
*/
|
||||
private static final MediaType MEDIA_TYPE_APPLICATION_JSON = MediaType.get("application/json; charset=utf-8");
|
||||
|
||||
/**
|
||||
* Shared object representing an empty request body in JSON.
|
||||
*/
|
||||
private static final RequestBody REQUEST_BODY_EMPTY_JSON = RequestBody.create(MEDIA_TYPE_APPLICATION_JSON, "");
|
||||
|
||||
/**
|
||||
* JSON Object Mapper.
|
||||
*/
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
/**
|
||||
* Base Url for calling Dapr. (e.g. http://localhost:3500/)
|
||||
*/
|
||||
private final String baseUrl;
|
||||
|
||||
/**
|
||||
* Http client used for all API calls.
|
||||
*/
|
||||
private final OkHttpClient httpClient;
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link DaprHttpAsyncClient}.
|
||||
* @param baseUrl Base Url for calling Dapr. (e.g. http://localhost:3500/)
|
||||
* @param httpClient RestClient used for all API calls in this new instance.
|
||||
*/
|
||||
DaprHttpAsyncClient(String baseUrl, OkHttpClient httpClient)
|
||||
{
|
||||
this.baseUrl = baseUrl;
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<String> invokeActorMethod(String actorType, String actorId, String methodName, String jsonPayload) {
|
||||
String url = String.format(Constants.ACTOR_METHOD_RELATIVE_URL_FORMAT, actorType, actorId, methodName);
|
||||
return invokeAPI("PUT", url, jsonPayload);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<String> getState(String actorType, String actorId, String keyName) {
|
||||
String url = String.format(Constants.ACTOR_STATE_KEY_RELATIVE_URL_FORMAT, actorType, actorId, keyName);
|
||||
return invokeAPI("GET", url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> removeState(String actorType, String actorId, String keyName) {
|
||||
String url = String.format(Constants.ACTOR_STATE_KEY_RELATIVE_URL_FORMAT, actorType, actorId, keyName);
|
||||
return invokeAPIVoid("DELETE", url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> saveStateTransactionally(String actorType, String actorId, String data) {
|
||||
String url = String.format(Constants.ACTOR_STATE_RELATIVE_URL_FORMAT, actorType, actorId);
|
||||
return invokeAPIVoid("PUT", url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> registerReminder(String actorType, String actorId, String reminderName, String data) {
|
||||
String url = String.format(Constants.ACTOR_REMINDER_RELATIVE_URL_FORMAT, actorType, actorId, reminderName);
|
||||
return invokeAPIVoid("PUT", url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> unregisterReminder(String actorType, String actorId, String reminderName) {
|
||||
String url = String.format(Constants.ACTOR_REMINDER_RELATIVE_URL_FORMAT, actorType, actorId, reminderName);
|
||||
return invokeAPIVoid("DELETE", url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> registerTimer(String actorType, String actorId, String timerName, String data) {
|
||||
String url = String.format(Constants.ACTOR_TIMER_RELATIVE_URL_FORMAT, actorType, actorId, timerName);
|
||||
return invokeAPIVoid("PUT", url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> unregisterTimerAsync(String actorType, String actorId, String timerName) {
|
||||
String url = String.format(Constants.ACTOR_TIMER_RELATIVE_URL_FORMAT, actorType, actorId, timerName);
|
||||
return invokeAPIVoid("DELETE", url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes an API asynchronously that returns Void.
|
||||
* @param method HTTP method.
|
||||
* @param urlString url as String.
|
||||
* @param json JSON payload or null.
|
||||
* @return Asynchronous Void
|
||||
*/
|
||||
private final Mono<Void> invokeAPIVoid(String method, String urlString, String json) {
|
||||
return this.invokeAPI(method, urlString, json).then();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes an API asynchronously that returns a text payload.
|
||||
* @param method HTTP method.
|
||||
* @param urlString url as String.
|
||||
* @param json JSON payload or null.
|
||||
* @return Asynchronous text
|
||||
*/
|
||||
private final Mono<String> invokeAPI(String method, String urlString, String json) {
|
||||
return Mono.fromSupplier(() -> {
|
||||
try {
|
||||
return tryInvokeAPI(method, urlString, json);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes an API synchronously and returns a text payload.
|
||||
* @param method HTTP method.
|
||||
* @param urlString url as String.
|
||||
* @param json JSON payload or null.
|
||||
* @return text
|
||||
*/
|
||||
private final String tryInvokeAPI(String method, String urlString, String json) throws IOException {
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
RequestBody body = json != null ? RequestBody.create(MEDIA_TYPE_APPLICATION_JSON, json) : REQUEST_BODY_EMPTY_JSON;
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url(new URL(this.baseUrl + urlString))
|
||||
.method(method, body)
|
||||
.addHeader(Constants.HEADER_DAPR_REQUEST_ID, requestId)
|
||||
.build();
|
||||
|
||||
Response response = this.httpClient.newCall(request).execute();
|
||||
if (!response.isSuccessful())
|
||||
{
|
||||
DaprError error = parseDaprError(response.body().string());
|
||||
if ((error != null) && (error.getErrorCode() != null) && (error.getMessage() != null)) {
|
||||
throw new DaprException(error);
|
||||
}
|
||||
|
||||
throw new DaprException("UNKNOWN", String.format("Dapr's Actor API %s failed with return code %d %s", urlString, response.code()));
|
||||
}
|
||||
|
||||
return response.body().string();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse an error from Dapr response body.
|
||||
* @param json Response body from Dapr.
|
||||
* @return DaprError or null if could not parse.
|
||||
*/
|
||||
private static DaprError parseDaprError(String json) {
|
||||
if (json == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return OBJECT_MAPPER.readValue(json, DaprError.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.actors;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Integration test for the HTTP Async Client.
|
||||
*
|
||||
* Requires Dapr running.
|
||||
*/
|
||||
public class DaprHttpAsyncClientIT {
|
||||
|
||||
/**
|
||||
* Checks if the error is correctly parsed when trying to invoke a function on an unknown actor type.
|
||||
*/
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void invokeUnknownActor() {
|
||||
DaprAsyncClient daprAsyncClient = new DaprClientBuilder().buildAsyncClient();
|
||||
daprAsyncClient
|
||||
.invokeActorMethod("ActorThatDoesNotExist", "100", "GetData", null)
|
||||
.doOnError(x -> {
|
||||
Assert.assertTrue(x instanceof RuntimeException);
|
||||
RuntimeException runtimeException = (RuntimeException)x;
|
||||
|
||||
Throwable cause = runtimeException.getCause();
|
||||
Assert.assertTrue(cause instanceof DaprException);
|
||||
DaprException daprException = (DaprException)cause;
|
||||
|
||||
Assert.assertNotNull(daprException);
|
||||
Assert.assertEquals("ERR_INVOKE_ACTOR", daprException.getErrorCode());
|
||||
Assert.assertNotNull(daprException.getMessage());
|
||||
Assert.assertFalse(daprException.getMessage().isEmpty());
|
||||
})
|
||||
.doOnSuccess(x -> Assert.fail("This call should fail."))
|
||||
.block();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue