mirror of https://github.com/dapr/java-sdk.git
New example for Dapr's Grpc invoke using Java.
Adds documentation for the other samples too.
This commit is contained in:
parent
48556cbefd
commit
e09debc228
|
@ -19,10 +19,11 @@ Then head over to build the Maven project:
|
|||
mvn install
|
||||
```
|
||||
|
||||
### Running an example
|
||||
```sh
|
||||
dapr run --protocol grpc --grpc-port 50001 -- mvn exec:java -pl examples -Dexec.mainClass=io.dapr.examples.Example
|
||||
```
|
||||
### Running the examples
|
||||
Try the following examples to learn more about Dapr's Java SDK:
|
||||
* [Invoking a service via Grpc](./examples/src/main/java/io/dapr/examples/invoke/grpc)
|
||||
* [State management over Grpc](./examples/src/main/java/io/dapr/examples/state/grpc)
|
||||
* [State management over HTTP](./examples/src/main/java/io/dapr/examples/state/http)
|
||||
|
||||
### Creating and publishing the artifacts to Nexus Repository
|
||||
From the root directory:
|
||||
|
|
|
@ -15,12 +15,49 @@
|
|||
<version>0.3.0-alpha</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>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20190722</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-protobuf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-stub</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-testing</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>${protobuf.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.os72</groupId>
|
||||
<artifactId>protoc-jar-maven-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dapr</groupId>
|
||||
<artifactId>dapr-sdk</artifactId>
|
||||
|
@ -28,4 +65,41 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.github.os72</groupId>
|
||||
<artifactId>protoc-jar-maven-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<protocVersion>${protobuf.version}</protocVersion>
|
||||
<addProtoSources>inputs</addProtoSources>
|
||||
<includeMavenTypes>direct</includeMavenTypes>
|
||||
<includeStdTypes>true</includeStdTypes>
|
||||
<inputDirectories>
|
||||
<include>${protobuf.input.directory}/examples</include>
|
||||
</inputDirectories>
|
||||
<outputTargets>
|
||||
<outputTarget>
|
||||
<type>java</type>
|
||||
<outputDirectory>${protobuf.output.directory}</outputDirectory>
|
||||
</outputTarget>
|
||||
<outputTarget>
|
||||
<type>grpc-java</type>
|
||||
<outputDirectory>${protobuf.output.directory}</outputDirectory>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}</pluginArtifact>
|
||||
</outputTarget>
|
||||
</outputTargets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package io.dapr.examples;
|
||||
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.dapr.DaprGrpc;
|
||||
import io.dapr.DaprGrpc.DaprBlockingStub;
|
||||
import io.dapr.DaprProtos.*;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
|
||||
/**
|
||||
* Simple example, to run:
|
||||
* mvn clean install
|
||||
* dapr run --grpc-port 50001 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.Example
|
||||
*/
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ManagedChannel channel =
|
||||
ManagedChannelBuilder.forAddress("localhost", 50001).usePlaintext().build();
|
||||
DaprBlockingStub client = DaprGrpc.newBlockingStub(channel);
|
||||
|
||||
Any data = Any.newBuilder().setValue(ByteString.copyFromUtf8("foo")).build();
|
||||
client.publishEvent(PublishEventEnvelope.newBuilder().setTopic("foo").setData(data).build());
|
||||
System.out.println("Published!");
|
||||
|
||||
String key = "mykey";
|
||||
StateRequest req = StateRequest.newBuilder()
|
||||
.setKey(key)
|
||||
.setValue(Any.newBuilder().setValue(ByteString.copyFromUtf8("my value")).build())
|
||||
.build();
|
||||
SaveStateEnvelope state = SaveStateEnvelope.newBuilder()
|
||||
.addRequests(req)
|
||||
.build();
|
||||
client.saveState(state);
|
||||
System.out.println("Saved!");
|
||||
|
||||
GetStateResponseEnvelope get = client.getState(GetStateEnvelope.newBuilder().setKey(key).build());
|
||||
System.out.println("Got: " + get.getData().getValue().toStringUtf8());
|
||||
|
||||
client.deleteState(DeleteStateEnvelope.newBuilder().setKey(key).build());
|
||||
System.out.println("Deleted!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
package io.dapr.examples.invoke.grpc;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import io.dapr.DaprGrpc;
|
||||
import io.dapr.DaprProtos.InvokeServiceEnvelope;
|
||||
import io.dapr.DaprProtos.InvokeServiceResponseEnvelope;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static io.dapr.examples.DaprExamplesProtos.SayRequest;
|
||||
import static io.dapr.examples.DaprExamplesProtos.SayResponse;
|
||||
|
||||
/**
|
||||
* 1. Build and install jars:
|
||||
* mvn clean install
|
||||
* 2. Send messages to the server:
|
||||
* dapr run --protocol grpc --grpc-port 50001 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.invoke.grpc.HelloWorldClient -Dexec.args="-p 50001 'message one' 'message two'"
|
||||
*/
|
||||
public class HelloWorldClient {
|
||||
|
||||
/**
|
||||
* Client mode: class representing a client-side logic for calling HelloWorld over Dapr.
|
||||
*/
|
||||
private static class GrpcHelloWorldDaprClient {
|
||||
|
||||
/**
|
||||
* Client communication channel: host, port and tls(on/off)
|
||||
*/
|
||||
private final ManagedChannel channel;
|
||||
|
||||
/**
|
||||
* Calls will be done asynchronously.
|
||||
*/
|
||||
private final DaprGrpc.DaprFutureStub client;
|
||||
|
||||
/**
|
||||
* Creates a Grpc client for the DaprGrpc service.
|
||||
* @param host host for the remote service endpoint
|
||||
* @param port port for the remote service endpoint
|
||||
*/
|
||||
public GrpcHelloWorldDaprClient(String host, int port) {
|
||||
this(ManagedChannelBuilder
|
||||
.forAddress("localhost", port)
|
||||
.usePlaintext() // SSL/TLS is default, we turn it off just because this is a sample and not prod.
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper constructor to build client from channel.
|
||||
* @param channel
|
||||
*/
|
||||
private GrpcHelloWorldDaprClient(ManagedChannel channel) {
|
||||
this.channel = channel;
|
||||
this.client = DaprGrpc.newFutureStub(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client mode: sends messages, one per second.
|
||||
* @param messages
|
||||
*/
|
||||
private void sendMessages(String... messages) throws ExecutionException, InterruptedException, InvalidProtocolBufferException {
|
||||
List<ListenableFuture<InvokeServiceResponseEnvelope>> futureResponses = new ArrayList<>();
|
||||
for (String message : messages)
|
||||
{
|
||||
SayRequest request = SayRequest
|
||||
.newBuilder()
|
||||
.setMessage(message)
|
||||
.build();
|
||||
|
||||
// Now, wrap the request with Dapr's envelope.
|
||||
InvokeServiceEnvelope requestEnvelope = InvokeServiceEnvelope
|
||||
.newBuilder()
|
||||
.setId("hellogrpc") // Service's identifier.
|
||||
.setData(Any.pack(request))
|
||||
.setMethod("say") // The service's method to be invoked by Dapr.
|
||||
.build();
|
||||
|
||||
futureResponses.add(client.invokeService(requestEnvelope));
|
||||
System.out.println("Client: sent => " + message);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
|
||||
}
|
||||
|
||||
for (ListenableFuture<InvokeServiceResponseEnvelope> future : futureResponses) {
|
||||
Any data = future.get().getData(); // Blocks waiting for response.
|
||||
// IMPORTANT: do not use Any.unpack(), use Type.ParseFrom() instead.
|
||||
SayResponse response = SayResponse.parseFrom(data.getValue());
|
||||
System.out.println("Client: got response => " + response.getTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Client mode: gracefully shutdown client within 1 min, otherwise force it.
|
||||
* @throws InterruptedException Propagated interrupted exception.
|
||||
*/
|
||||
private void shutdown() throws InterruptedException {
|
||||
this.channel.shutdown().awaitTermination(1, TimeUnit.MINUTES);
|
||||
System.out.println("Client: Bye.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Options options = new Options();
|
||||
options.addRequiredOption("p", "port", true, "Port to listen or send event to.");
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine cmd = parser.parse(options, args);
|
||||
|
||||
// If port string is not valid, it will throw an exception.
|
||||
int port = Integer.parseInt(cmd.getOptionValue("port"));
|
||||
|
||||
GrpcHelloWorldDaprClient helloWorldClient = new GrpcHelloWorldDaprClient("localhost", port);
|
||||
helloWorldClient.sendMessages(cmd.getArgs());
|
||||
helloWorldClient.shutdown();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package io.dapr.examples.invoke.grpc;
|
||||
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import io.dapr.DaprClientGrpc;
|
||||
import io.dapr.DaprClientProtos;
|
||||
import io.grpc.Server;
|
||||
import io.grpc.ServerBuilder;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static io.dapr.examples.DaprExamplesProtos.SayRequest;
|
||||
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"
|
||||
*/
|
||||
public class HelloWorldService {
|
||||
|
||||
/**
|
||||
* Server mode: class that encapsulates all server-side logic for Grpc.
|
||||
*/
|
||||
private static class GrpcHelloWorldDaprService extends DaprClientGrpc.DaprClientImplBase {
|
||||
|
||||
/**
|
||||
* Format to output date and time.
|
||||
*/
|
||||
private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
/**
|
||||
* Server mode: Grpc server.
|
||||
*/
|
||||
private Server server;
|
||||
|
||||
/**
|
||||
* Server mode: starts listening on given port.
|
||||
*
|
||||
* @param port Port to listen on.
|
||||
* @throws IOException Errors while trying to start service.
|
||||
*/
|
||||
private void start(int port) throws IOException {
|
||||
this.server = ServerBuilder
|
||||
.forPort(port)
|
||||
.addService(this)
|
||||
.build()
|
||||
.start();
|
||||
System.out.printf("Server: started listening on port %d\n", port);
|
||||
|
||||
// Now we handle ctrl+c (or any other JVM shutdown)
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Server: shutting down gracefully ...");
|
||||
GrpcHelloWorldDaprService.this.server.shutdown();
|
||||
System.out.println("Server: Bye.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Server mode: waits for shutdown trigger.
|
||||
*
|
||||
* @throws InterruptedException Propagated interrupted exception.
|
||||
*/
|
||||
private void awaitTermination() throws InterruptedException {
|
||||
if (this.server != null) {
|
||||
this.server.awaitTermination();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Server mode: this is the Dapr method to receive Invoke operations via Grpc.
|
||||
*
|
||||
* @param request Dapr envelope request,
|
||||
* @param responseObserver Dapr envelope response.
|
||||
*/
|
||||
@Override
|
||||
public void onInvoke(DaprClientProtos.InvokeEnvelope request, StreamObserver<Any> responseObserver) {
|
||||
try {
|
||||
if ("say".equals(request.getMethod())) {
|
||||
// IMPORTANT: do not use Any.unpack(), use Type.ParseFrom() instead.
|
||||
SayRequest sayRequest = SayRequest.parseFrom(request.getData().getValue());
|
||||
SayResponse sayResponse = this.say(sayRequest);
|
||||
responseObserver.onNext(Any.pack(sayResponse));
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
} finally {
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handling of the 'say' method.
|
||||
*
|
||||
* @param request Request to say something.
|
||||
* @return Response with when it was said.
|
||||
*/
|
||||
public SayResponse say(SayRequest request) {
|
||||
Calendar utcNow = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
String utcNowAsString = DATE_FORMAT.format(utcNow.getTime());
|
||||
|
||||
// Handles the request by printing message.
|
||||
System.out.println("Server: " + request.getMessage() + " @ " + utcNowAsString);
|
||||
|
||||
// Now respond with current timestamp.
|
||||
SayResponse.Builder responseBuilder = SayResponse.newBuilder();
|
||||
return responseBuilder.setTimestamp(utcNowAsString).build();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Options options = new Options();
|
||||
options.addRequiredOption("p", "port", true, "Port to listen or send event to.");
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine cmd = parser.parse(options, args);
|
||||
|
||||
// If port string is not valid, it will throw an exception.
|
||||
int port = Integer.parseInt(cmd.getOptionValue("port"));
|
||||
|
||||
final GrpcHelloWorldDaprService service = new GrpcHelloWorldDaprService();
|
||||
service.start(port);
|
||||
service.awaitTermination();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
## Invoking a Grpc endpoint using the Java-SDK
|
||||
|
||||
In this example, you will run a Grpc service and client using Dapr's invoke feature.
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
* [Dapr and Dapr Cli](https://github.com/dapr/docs/blob/master/getting-started/environment-setup.md#environment-setup).
|
||||
* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
|
||||
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
|
||||
|
||||
### Checking out the code
|
||||
|
||||
Clone this repository:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/dapr/java-sdk.git
|
||||
cd java-sdk
|
||||
```
|
||||
|
||||
Then build the Maven project:
|
||||
|
||||
```sh
|
||||
# make sure you are in the `java-sdk` directory.
|
||||
mvn install
|
||||
```
|
||||
|
||||
### Running the example's service
|
||||
|
||||
The first component is the service. It has a simple API with the `Say` method. This method will print out each message received from the client. The proto file below contains the description of the HelloWorld service found in the `./proto/examples/helloworld.proto` file:
|
||||
|
||||
```text
|
||||
service HelloWorld {
|
||||
rpc Say (SayRequest) returns (SayResponse) {}
|
||||
}
|
||||
|
||||
message SayRequest {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
message SayResponse {
|
||||
string timestamp = 1;
|
||||
}
|
||||
```
|
||||
|
||||
In the `HelloWorldService.java` file, you will find the `HelloWorldService` class, containing the main method. The service implementation happens in the `GrpcHelloWorldDaprService` class. You can see that it extends `DaprClientImplBase` instead of `HelloWorldImplBase`. This is because this service will be called by Dapr, so it implements the service API expected by Dapr. The `DaprClientImplBase` class is part of this SDK. In a real-world application, the service would still implement its main API as well. The Dapr's API would be exposed as an additional service. In this example, we are implementing Dapr's API only. Modifying this example to expose `HelloWorldService` is offered as an exercise to the reader.
|
||||
```java
|
||||
private static class GrpcHelloWorldDaprService extends DaprClientGrpc.DaprClientImplBase {
|
||||
///...
|
||||
@Override
|
||||
public void onInvoke(DaprClientProtos.InvokeEnvelope request, StreamObserver<Any> responseObserver) {
|
||||
try {
|
||||
if ("say".equals(request.getMethod())) {
|
||||
// IMPORTANT: do not use Any.unpack(), use Type.ParseFrom() instead.
|
||||
SayRequest sayRequest = SayRequest.parseFrom(request.getData().getValue());
|
||||
SayResponse sayResponse = this.say(sayRequest);
|
||||
responseObserver.onNext(Any.pack(sayResponse));
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
responseObserver.onError(e);
|
||||
} finally {
|
||||
responseObserver.onCompleted();
|
||||
}
|
||||
}
|
||||
///...
|
||||
}
|
||||
```
|
||||
In the `GrpcHelloWorldDaprService` class, the `onInvoke` method is the most important. It is called by Dapr's runtime containing information that this code needs to redirect the request to the correct underlying method. In this case, the only method supported is the `say` method. So, it checks for the method requested and extracts the `SayRequest` object from Dapr's envelope request. Once a `SayResponse` instance is ready, it serializes it into Dapr's envelope response object and returns.
|
||||
|
||||
Now run the service code:
|
||||
|
||||
```sh
|
||||
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"
|
||||
```
|
||||
|
||||
The `app-id` argument is used to identify this service in Dapr's runtime. The `app-port` determines which port Dapr's runtime should call into this service. The `protocol` argument informs Dapr which protocol it should use: `grpc` or `http`(default).
|
||||
|
||||
### Running the example's client
|
||||
|
||||
The other component is the client. It will take in the messages via command line arguments and send each one to the service via Dapr's invoke API over Grpc. Open the `HelloWorldClient.java` file, it contains the `HelloWorldClient` class with the main method and also the `GrpcHelloWorldDaprClient` class. The `GrpcHelloWorldDaprClient` encapsulates an instance of the `DaprFutureStub` class because it is calling Dapr's API. Creating a client to call `HelloWorldService` directly can be an exercise for the reader. In the `GrpcHelloWorldDaprClient` class, the most important method is `sendMessages`. See the code snippet below:
|
||||
|
||||
```java
|
||||
private static class GrpcHelloWorldDaprClient {
|
||||
///...
|
||||
private void sendMessages(String... messages) throws ExecutionException, InterruptedException, InvalidProtocolBufferException {
|
||||
List<ListenableFuture<InvokeServiceResponseEnvelope>> futureResponses = new ArrayList<>();
|
||||
for (String message : messages)
|
||||
{
|
||||
SayRequest request = SayRequest
|
||||
.newBuilder()
|
||||
.setMessage(message)
|
||||
.build();
|
||||
|
||||
// Now, wrap the request with Dapr's envelope.
|
||||
InvokeServiceEnvelope requestEnvelope = InvokeServiceEnvelope
|
||||
.newBuilder()
|
||||
.setId("hellogrpc") // Service's identifier.
|
||||
.setData(Any.pack(request))
|
||||
.setMethod("say") // The service's method to be invoked by Dapr.
|
||||
.build();
|
||||
|
||||
futureResponses.add(client.invokeService(requestEnvelope));
|
||||
System.out.println("Client: sent => " + message);
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(10));
|
||||
}
|
||||
|
||||
for (ListenableFuture<InvokeServiceResponseEnvelope> future : futureResponses) {
|
||||
Any data = future.get().getData(); // Blocks waiting for response.
|
||||
// IMPORTANT: do not use Any.unpack(), use Type.ParseFrom() instead.
|
||||
SayResponse response = SayResponse.parseFrom(data.getValue());
|
||||
System.out.println("Client: got response => " + response.getTimestamp());
|
||||
}
|
||||
}
|
||||
///...
|
||||
}
|
||||
```
|
||||
|
||||
First, it goes through each message and creates a corresponding `SayRequest` object as if it would call the `HelloWorld` service directly. Then, the request object is wrapped into an instance of `InvokeServiceEnvelope`. As expected, the enveloped request is sent to Dapr's `invokeService` method. Once all responses are completed, they are unwrapped into `SayResponse` objects.
|
||||
|
||||
Finally, open a new command line terminal and run the client code to send some messages. Feel free to play with the command line to send different messages:
|
||||
|
||||
```sh
|
||||
dapr run --protocol grpc --grpc-port 50001 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.invoke.grpc.HelloWorldClient -Dexec.args="-p 50001 'message one' 'message two'"
|
||||
```
|
||||
|
||||
Once the messages are sent, use `CTRL+C` to exit Dapr.
|
||||
|
||||
The `protocol` argument tells Dapr which protocol to use. In this command, `grpc-port` is specified so Dapr does not pick a random port and uses the requested port instead. The same port is passed in the client executable via the `p` argument. The last arguments into the Java's main method are the messages to be sent.
|
||||
|
||||
Thanks for playing.
|
|
@ -0,0 +1,61 @@
|
|||
package io.dapr.examples.state.grpc;
|
||||
|
||||
import com.google.protobuf.Any;
|
||||
import com.google.protobuf.ByteString;
|
||||
import io.dapr.DaprGrpc;
|
||||
import io.dapr.DaprGrpc.DaprBlockingStub;
|
||||
import io.dapr.DaprProtos.*;
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Simple example, to run:
|
||||
* mvn clean install
|
||||
* dapr run --grpc-port 50001 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.Example
|
||||
*/
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ManagedChannel channel =
|
||||
ManagedChannelBuilder.forAddress("localhost", 50001).usePlaintext().build();
|
||||
DaprBlockingStub client = DaprGrpc.newBlockingStub(channel);
|
||||
|
||||
String key = "mykey";
|
||||
// First, write key-value pair.
|
||||
{
|
||||
String value = UUID.randomUUID().toString();
|
||||
StateRequest req = StateRequest
|
||||
.newBuilder()
|
||||
.setKey(key)
|
||||
.setValue(Any.newBuilder().setValue(ByteString.copyFromUtf8(value)).build())
|
||||
.build();
|
||||
SaveStateEnvelope state = SaveStateEnvelope.newBuilder()
|
||||
.addRequests(req)
|
||||
.build();
|
||||
client.saveState(state);
|
||||
System.out.println("Saved!");
|
||||
}
|
||||
|
||||
// Now, read it back.
|
||||
{
|
||||
GetStateEnvelope req = GetStateEnvelope
|
||||
.newBuilder()
|
||||
.setKey(key)
|
||||
.build();
|
||||
GetStateResponseEnvelope response = client.getState(req);
|
||||
String value = response.getData().getValue().toStringUtf8();
|
||||
System.out.println("Got: " + value);
|
||||
}
|
||||
|
||||
// Then, delete it.
|
||||
{
|
||||
DeleteStateEnvelope req = DeleteStateEnvelope
|
||||
.newBuilder()
|
||||
.setKey(key)
|
||||
.build();
|
||||
client.deleteState(req);
|
||||
System.out.println("Deleted!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
## State management via Dapr's Grpc endpoint using the Java-SDK
|
||||
|
||||
This example shows how to write and read data on Dapr via Grpc.
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
* [Dapr and Dapr Cli](https://github.com/dapr/docs/blob/master/getting-started/environment-setup.md#environment-setup).
|
||||
* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
|
||||
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
|
||||
|
||||
### Checking out the code
|
||||
|
||||
Clone this repository:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/dapr/java-sdk.git
|
||||
cd java-sdk
|
||||
```
|
||||
|
||||
Then build the Maven project:
|
||||
|
||||
```sh
|
||||
# make sure you are in the `java-sdk` directory.
|
||||
mvn install
|
||||
```
|
||||
|
||||
### Understanding the code
|
||||
|
||||
Open the file `Example.java`, it contains the client to communicate to Dapr's runtime. In this example, we will be using port 50001 and use the blocking (instead of asynchronous) client:
|
||||
```
|
||||
ManagedChannel channel =
|
||||
ManagedChannelBuilder.forAddress("localhost", 50001).usePlaintext().build();
|
||||
DaprBlockingStub client = DaprGrpc.newBlockingStub(channel);
|
||||
```
|
||||
|
||||
The code has 3 parts: save, read and delete a key-value pair.
|
||||
|
||||
First, save a key-value pair to the state store using the `saveState` method.
|
||||
```
|
||||
StateRequest req = StateRequest
|
||||
.newBuilder()
|
||||
.setKey(key)
|
||||
.setValue(Any.newBuilder().setValue(ByteString.copyFromUtf8(value)).build())
|
||||
.build();
|
||||
SaveStateEnvelope state = SaveStateEnvelope.newBuilder()
|
||||
.addRequests(req)
|
||||
.build();
|
||||
client.saveState(state);
|
||||
```
|
||||
|
||||
Then, read it:
|
||||
```
|
||||
GetStateEnvelope req = GetStateEnvelope
|
||||
.newBuilder()
|
||||
.setKey(key)
|
||||
.build();
|
||||
GetStateResponseEnvelope response = client.getState(req);
|
||||
String value = response.getData().getValue().toStringUtf8();
|
||||
```
|
||||
|
||||
In the end, delete it:
|
||||
```
|
||||
DeleteStateEnvelope req = DeleteStateEnvelope
|
||||
.newBuilder()
|
||||
.setKey(key)
|
||||
.build();
|
||||
client.deleteState(req);
|
||||
```
|
||||
|
||||
### Running the example
|
||||
|
||||
Finally, run this example with the following command:
|
||||
```sh
|
||||
dapr run --grpc-port 50001 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.state.grpc.Example
|
||||
```
|
||||
|
||||
To find more features available in the Dapr's Grpc API, see [dapr.proto](../../../../../../../../../proto/dapr/dapr.proto).
|
||||
|
||||
Thanks for playing.
|
|
@ -1,4 +1,4 @@
|
|||
package io.dapr.examples;
|
||||
package io.dapr.examples.state.http;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
|
@ -34,7 +34,7 @@ import static java.lang.System.out;
|
|||
* mvn clean install
|
||||
*
|
||||
* To run (after step above):
|
||||
* dapr run --app-id orderapp --app-port 3000 --port 3500 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.OrderManager
|
||||
* dapr run --app-id orderapp --app-port 3000 --port 3500 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.state.http.OrderManager
|
||||
*
|
||||
* If this class changes, run this before running it again:
|
||||
* mvn compile
|
|
@ -0,0 +1,113 @@
|
|||
## State management via Dapr's HTTP endpoint using the Java-SDK
|
||||
|
||||
This example shows how to write and read data on Dapr via HTTP.
|
||||
|
||||
## Pre-requisites
|
||||
|
||||
* [Dapr and Dapr Cli](https://github.com/dapr/docs/blob/master/getting-started/environment-setup.md#environment-setup).
|
||||
* Java JDK 11 (or greater): [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11) or [OpenJDK](https://jdk.java.net/13/).
|
||||
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.
|
||||
|
||||
### Checking out the code
|
||||
|
||||
Clone this repository:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/dapr/java-sdk.git
|
||||
cd java-sdk
|
||||
```
|
||||
|
||||
Then build the Maven project:
|
||||
|
||||
```sh
|
||||
# make sure you are in the `java-sdk` directory.
|
||||
mvn install
|
||||
```
|
||||
|
||||
### Understanding the code
|
||||
|
||||
This example implements a service listening on port 3000, while using Dapr's state store via port 3500. Its API also offers two methods: `/order` and `/neworder`. Calls to '/order' will fetch the state from Dapr's state store:
|
||||
|
||||
```
|
||||
String stateUrl = String.format("http://localhost:%s/v1.0/state", daprPort);
|
||||
/// ...
|
||||
httpServer.createContext("/order").setHandler(e -> {
|
||||
out.println("Fetching order!");
|
||||
fetch(stateUrl + "/order").thenAccept(response -> {
|
||||
int resCode = response.statusCode() == 200 ? 200 : 500;
|
||||
String body = response.statusCode() == 200 ? response.body() : "Could not get state.";
|
||||
|
||||
try {
|
||||
e.sendResponseHeaders(resCode, body.getBytes().length);
|
||||
OutputStream os = e.getResponseBody();
|
||||
try {
|
||||
os.write(body.getBytes());
|
||||
} finally {
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException ioerror) {
|
||||
out.println(ioerror);
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Calls to `/neworder` will persist a new state do Dapr's state store:
|
||||
```
|
||||
httpServer.createContext("/neworder").setHandler(e -> {
|
||||
try {
|
||||
out.println("Received new order ...");
|
||||
String json = readBody(e);
|
||||
JSONObject jsonObject = new JSONObject(json);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String orderId = data.getString("orderId");
|
||||
out.printf("Got a new order! Order ID: %s\n", orderId);
|
||||
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("key", "order");
|
||||
item.put("value", data);
|
||||
JSONArray state = new JSONArray();
|
||||
state.put(item);
|
||||
out.printf("Writing to state: %s\n", state.toString());
|
||||
|
||||
post(stateUrl, state.toString()).thenAccept(response -> {
|
||||
int resCode = response.statusCode() == 200 ? 200 : 500;
|
||||
String body = response.body();
|
||||
try {
|
||||
e.sendResponseHeaders(resCode, body.getBytes().length);
|
||||
OutputStream os = e.getResponseBody();
|
||||
try {
|
||||
os.write(body.getBytes());
|
||||
} finally {
|
||||
os.close();
|
||||
}
|
||||
} catch (IOException ioerror) {
|
||||
out.println(ioerror);
|
||||
}
|
||||
});
|
||||
} catch (IOException ioerror) {
|
||||
out.println(ioerror);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Running the example
|
||||
|
||||
Now, run this example with the following command:
|
||||
```sh
|
||||
dapr run --app-id orderapp --app-port 3000 --port 3500 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.state.http.OrderManager
|
||||
```
|
||||
|
||||
Use Dapr cli to invoke the APIs for this service. Initially, save a new order:
|
||||
```sh
|
||||
dapr invoke --app-id orderapp --method neworder --payload "{\"data\": { \"orderId\": \"41\" } }"
|
||||
```
|
||||
|
||||
See the last order by invoking the `/order` method:
|
||||
```sh
|
||||
dapr invoke --app-id orderapp --method order
|
||||
```
|
||||
|
||||
Finally, change the values for `orderId` and see if it gets updated by invoking `/order` again.
|
||||
|
||||
Thanks for playing.
|
File diff suppressed because it is too large
Load Diff
|
@ -1,818 +0,0 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: daprclient.proto
|
||||
|
||||
package daprclient
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
any "github.com/golang/protobuf/ptypes/any"
|
||||
duration "github.com/golang/protobuf/ptypes/duration"
|
||||
empty "github.com/golang/protobuf/ptypes/empty"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type CloudEventEnvelope struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
|
||||
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
|
||||
SpecVersion string `protobuf:"bytes,4,opt,name=specVersion,proto3" json:"specVersion,omitempty"`
|
||||
DataContentType string `protobuf:"bytes,5,opt,name=dataContentType,proto3" json:"dataContentType,omitempty"`
|
||||
Topic string `protobuf:"bytes,6,opt,name=topic,proto3" json:"topic,omitempty"`
|
||||
Data *any.Any `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) Reset() { *m = CloudEventEnvelope{} }
|
||||
func (m *CloudEventEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*CloudEventEnvelope) ProtoMessage() {}
|
||||
func (*CloudEventEnvelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{0}
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CloudEventEnvelope.Unmarshal(m, b)
|
||||
}
|
||||
func (m *CloudEventEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_CloudEventEnvelope.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *CloudEventEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_CloudEventEnvelope.Merge(m, src)
|
||||
}
|
||||
func (m *CloudEventEnvelope) XXX_Size() int {
|
||||
return xxx_messageInfo_CloudEventEnvelope.Size(m)
|
||||
}
|
||||
func (m *CloudEventEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_CloudEventEnvelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_CloudEventEnvelope proto.InternalMessageInfo
|
||||
|
||||
func (m *CloudEventEnvelope) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) GetSource() string {
|
||||
if m != nil {
|
||||
return m.Source
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) GetType() string {
|
||||
if m != nil {
|
||||
return m.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) GetSpecVersion() string {
|
||||
if m != nil {
|
||||
return m.SpecVersion
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) GetDataContentType() string {
|
||||
if m != nil {
|
||||
return m.DataContentType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) GetTopic() string {
|
||||
if m != nil {
|
||||
return m.Topic
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *CloudEventEnvelope) GetData() *any.Any {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type BindingEventEnvelope struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Data *any.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *BindingEventEnvelope) Reset() { *m = BindingEventEnvelope{} }
|
||||
func (m *BindingEventEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*BindingEventEnvelope) ProtoMessage() {}
|
||||
func (*BindingEventEnvelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{1}
|
||||
}
|
||||
|
||||
func (m *BindingEventEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_BindingEventEnvelope.Unmarshal(m, b)
|
||||
}
|
||||
func (m *BindingEventEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BindingEventEnvelope.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *BindingEventEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BindingEventEnvelope.Merge(m, src)
|
||||
}
|
||||
func (m *BindingEventEnvelope) XXX_Size() int {
|
||||
return xxx_messageInfo_BindingEventEnvelope.Size(m)
|
||||
}
|
||||
func (m *BindingEventEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BindingEventEnvelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BindingEventEnvelope proto.InternalMessageInfo
|
||||
|
||||
func (m *BindingEventEnvelope) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *BindingEventEnvelope) GetData() *any.Any {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BindingEventEnvelope) GetMetadata() map[string]string {
|
||||
if m != nil {
|
||||
return m.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type BindingResponseEnvelope struct {
|
||||
Data *any.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||
To []string `protobuf:"bytes,2,rep,name=to,proto3" json:"to,omitempty"`
|
||||
State []*State `protobuf:"bytes,3,rep,name=state,proto3" json:"state,omitempty"`
|
||||
Concurrency string `protobuf:"bytes,4,opt,name=concurrency,proto3" json:"concurrency,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *BindingResponseEnvelope) Reset() { *m = BindingResponseEnvelope{} }
|
||||
func (m *BindingResponseEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*BindingResponseEnvelope) ProtoMessage() {}
|
||||
func (*BindingResponseEnvelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{2}
|
||||
}
|
||||
|
||||
func (m *BindingResponseEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_BindingResponseEnvelope.Unmarshal(m, b)
|
||||
}
|
||||
func (m *BindingResponseEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BindingResponseEnvelope.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *BindingResponseEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BindingResponseEnvelope.Merge(m, src)
|
||||
}
|
||||
func (m *BindingResponseEnvelope) XXX_Size() int {
|
||||
return xxx_messageInfo_BindingResponseEnvelope.Size(m)
|
||||
}
|
||||
func (m *BindingResponseEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BindingResponseEnvelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BindingResponseEnvelope proto.InternalMessageInfo
|
||||
|
||||
func (m *BindingResponseEnvelope) GetData() *any.Any {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BindingResponseEnvelope) GetTo() []string {
|
||||
if m != nil {
|
||||
return m.To
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BindingResponseEnvelope) GetState() []*State {
|
||||
if m != nil {
|
||||
return m.State
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BindingResponseEnvelope) GetConcurrency() string {
|
||||
if m != nil {
|
||||
return m.Concurrency
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type InvokeEnvelope struct {
|
||||
Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
|
||||
Data *any.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *InvokeEnvelope) Reset() { *m = InvokeEnvelope{} }
|
||||
func (m *InvokeEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*InvokeEnvelope) ProtoMessage() {}
|
||||
func (*InvokeEnvelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{3}
|
||||
}
|
||||
|
||||
func (m *InvokeEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_InvokeEnvelope.Unmarshal(m, b)
|
||||
}
|
||||
func (m *InvokeEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_InvokeEnvelope.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *InvokeEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_InvokeEnvelope.Merge(m, src)
|
||||
}
|
||||
func (m *InvokeEnvelope) XXX_Size() int {
|
||||
return xxx_messageInfo_InvokeEnvelope.Size(m)
|
||||
}
|
||||
func (m *InvokeEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_InvokeEnvelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_InvokeEnvelope proto.InternalMessageInfo
|
||||
|
||||
func (m *InvokeEnvelope) GetMethod() string {
|
||||
if m != nil {
|
||||
return m.Method
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *InvokeEnvelope) GetData() *any.Any {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *InvokeEnvelope) GetMetadata() map[string]string {
|
||||
if m != nil {
|
||||
return m.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetTopicSubscriptionsEnvelope struct {
|
||||
Topics []string `protobuf:"bytes,1,rep,name=topics,proto3" json:"topics,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetTopicSubscriptionsEnvelope) Reset() { *m = GetTopicSubscriptionsEnvelope{} }
|
||||
func (m *GetTopicSubscriptionsEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetTopicSubscriptionsEnvelope) ProtoMessage() {}
|
||||
func (*GetTopicSubscriptionsEnvelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{4}
|
||||
}
|
||||
|
||||
func (m *GetTopicSubscriptionsEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetTopicSubscriptionsEnvelope.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetTopicSubscriptionsEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetTopicSubscriptionsEnvelope.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetTopicSubscriptionsEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetTopicSubscriptionsEnvelope.Merge(m, src)
|
||||
}
|
||||
func (m *GetTopicSubscriptionsEnvelope) XXX_Size() int {
|
||||
return xxx_messageInfo_GetTopicSubscriptionsEnvelope.Size(m)
|
||||
}
|
||||
func (m *GetTopicSubscriptionsEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetTopicSubscriptionsEnvelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetTopicSubscriptionsEnvelope proto.InternalMessageInfo
|
||||
|
||||
func (m *GetTopicSubscriptionsEnvelope) GetTopics() []string {
|
||||
if m != nil {
|
||||
return m.Topics
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetBindingsSubscriptionsEnvelope struct {
|
||||
Bindings []string `protobuf:"bytes,1,rep,name=bindings,proto3" json:"bindings,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetBindingsSubscriptionsEnvelope) Reset() { *m = GetBindingsSubscriptionsEnvelope{} }
|
||||
func (m *GetBindingsSubscriptionsEnvelope) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetBindingsSubscriptionsEnvelope) ProtoMessage() {}
|
||||
func (*GetBindingsSubscriptionsEnvelope) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{5}
|
||||
}
|
||||
|
||||
func (m *GetBindingsSubscriptionsEnvelope) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetBindingsSubscriptionsEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetBindingsSubscriptionsEnvelope) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Merge(m, src)
|
||||
}
|
||||
func (m *GetBindingsSubscriptionsEnvelope) XXX_Size() int {
|
||||
return xxx_messageInfo_GetBindingsSubscriptionsEnvelope.Size(m)
|
||||
}
|
||||
func (m *GetBindingsSubscriptionsEnvelope) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetBindingsSubscriptionsEnvelope.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetBindingsSubscriptionsEnvelope proto.InternalMessageInfo
|
||||
|
||||
func (m *GetBindingsSubscriptionsEnvelope) GetBindings() []string {
|
||||
if m != nil {
|
||||
return m.Bindings
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type State struct {
|
||||
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
||||
Value *any.Any `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
||||
Etag string `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"`
|
||||
Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Options *StateOptions `protobuf:"bytes,5,opt,name=options,proto3" json:"options,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *State) Reset() { *m = State{} }
|
||||
func (m *State) String() string { return proto.CompactTextString(m) }
|
||||
func (*State) ProtoMessage() {}
|
||||
func (*State) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{6}
|
||||
}
|
||||
|
||||
func (m *State) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_State.Unmarshal(m, b)
|
||||
}
|
||||
func (m *State) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_State.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *State) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_State.Merge(m, src)
|
||||
}
|
||||
func (m *State) XXX_Size() int {
|
||||
return xxx_messageInfo_State.Size(m)
|
||||
}
|
||||
func (m *State) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_State.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_State proto.InternalMessageInfo
|
||||
|
||||
func (m *State) GetKey() string {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *State) GetValue() *any.Any {
|
||||
if m != nil {
|
||||
return m.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *State) GetEtag() string {
|
||||
if m != nil {
|
||||
return m.Etag
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *State) GetMetadata() map[string]string {
|
||||
if m != nil {
|
||||
return m.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *State) GetOptions() *StateOptions {
|
||||
if m != nil {
|
||||
return m.Options
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type StateOptions struct {
|
||||
Concurrency string `protobuf:"bytes,1,opt,name=concurrency,proto3" json:"concurrency,omitempty"`
|
||||
Consistency string `protobuf:"bytes,2,opt,name=consistency,proto3" json:"consistency,omitempty"`
|
||||
RetryPolicy *RetryPolicy `protobuf:"bytes,3,opt,name=retryPolicy,proto3" json:"retryPolicy,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *StateOptions) Reset() { *m = StateOptions{} }
|
||||
func (m *StateOptions) String() string { return proto.CompactTextString(m) }
|
||||
func (*StateOptions) ProtoMessage() {}
|
||||
func (*StateOptions) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{7}
|
||||
}
|
||||
|
||||
func (m *StateOptions) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StateOptions.Unmarshal(m, b)
|
||||
}
|
||||
func (m *StateOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_StateOptions.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *StateOptions) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_StateOptions.Merge(m, src)
|
||||
}
|
||||
func (m *StateOptions) XXX_Size() int {
|
||||
return xxx_messageInfo_StateOptions.Size(m)
|
||||
}
|
||||
func (m *StateOptions) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_StateOptions.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_StateOptions proto.InternalMessageInfo
|
||||
|
||||
func (m *StateOptions) GetConcurrency() string {
|
||||
if m != nil {
|
||||
return m.Concurrency
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *StateOptions) GetConsistency() string {
|
||||
if m != nil {
|
||||
return m.Consistency
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *StateOptions) GetRetryPolicy() *RetryPolicy {
|
||||
if m != nil {
|
||||
return m.RetryPolicy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type RetryPolicy struct {
|
||||
Threshold int32 `protobuf:"varint,1,opt,name=threshold,proto3" json:"threshold,omitempty"`
|
||||
Pattern string `protobuf:"bytes,2,opt,name=pattern,proto3" json:"pattern,omitempty"`
|
||||
Interval *duration.Duration `protobuf:"bytes,3,opt,name=interval,proto3" json:"interval,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *RetryPolicy) Reset() { *m = RetryPolicy{} }
|
||||
func (m *RetryPolicy) String() string { return proto.CompactTextString(m) }
|
||||
func (*RetryPolicy) ProtoMessage() {}
|
||||
func (*RetryPolicy) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_127d5244029ccc8f, []int{8}
|
||||
}
|
||||
|
||||
func (m *RetryPolicy) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_RetryPolicy.Unmarshal(m, b)
|
||||
}
|
||||
func (m *RetryPolicy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_RetryPolicy.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *RetryPolicy) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_RetryPolicy.Merge(m, src)
|
||||
}
|
||||
func (m *RetryPolicy) XXX_Size() int {
|
||||
return xxx_messageInfo_RetryPolicy.Size(m)
|
||||
}
|
||||
func (m *RetryPolicy) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_RetryPolicy.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_RetryPolicy proto.InternalMessageInfo
|
||||
|
||||
func (m *RetryPolicy) GetThreshold() int32 {
|
||||
if m != nil {
|
||||
return m.Threshold
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *RetryPolicy) GetPattern() string {
|
||||
if m != nil {
|
||||
return m.Pattern
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *RetryPolicy) GetInterval() *duration.Duration {
|
||||
if m != nil {
|
||||
return m.Interval
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*CloudEventEnvelope)(nil), "daprclient.CloudEventEnvelope")
|
||||
proto.RegisterType((*BindingEventEnvelope)(nil), "daprclient.BindingEventEnvelope")
|
||||
proto.RegisterMapType((map[string]string)(nil), "daprclient.BindingEventEnvelope.MetadataEntry")
|
||||
proto.RegisterType((*BindingResponseEnvelope)(nil), "daprclient.BindingResponseEnvelope")
|
||||
proto.RegisterType((*InvokeEnvelope)(nil), "daprclient.InvokeEnvelope")
|
||||
proto.RegisterMapType((map[string]string)(nil), "daprclient.InvokeEnvelope.MetadataEntry")
|
||||
proto.RegisterType((*GetTopicSubscriptionsEnvelope)(nil), "daprclient.GetTopicSubscriptionsEnvelope")
|
||||
proto.RegisterType((*GetBindingsSubscriptionsEnvelope)(nil), "daprclient.GetBindingsSubscriptionsEnvelope")
|
||||
proto.RegisterType((*State)(nil), "daprclient.State")
|
||||
proto.RegisterMapType((map[string]string)(nil), "daprclient.State.MetadataEntry")
|
||||
proto.RegisterType((*StateOptions)(nil), "daprclient.StateOptions")
|
||||
proto.RegisterType((*RetryPolicy)(nil), "daprclient.RetryPolicy")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("daprclient.proto", fileDescriptor_127d5244029ccc8f) }
|
||||
|
||||
var fileDescriptor_127d5244029ccc8f = []byte{
|
||||
// 745 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x6e, 0xd3, 0x4a,
|
||||
0x10, 0x8e, 0x9d, 0x9f, 0xa6, 0x93, 0x9e, 0x9c, 0x9e, 0x51, 0x4f, 0xeb, 0x1a, 0x28, 0x91, 0xb9,
|
||||
0x20, 0x20, 0x94, 0x4a, 0x41, 0x88, 0x9f, 0x4a, 0x95, 0xa0, 0x8d, 0x0a, 0x48, 0x28, 0xc8, 0xad,
|
||||
0x90, 0x90, 0xb8, 0x71, 0x9c, 0x25, 0xb5, 0xea, 0xec, 0x5a, 0xeb, 0x4d, 0x24, 0x4b, 0xdc, 0x73,
|
||||
0xc5, 0x2b, 0xf0, 0x12, 0x3c, 0x0b, 0x77, 0xf0, 0x2e, 0xc8, 0xeb, 0x75, 0xb2, 0x8d, 0x93, 0x56,
|
||||
0x08, 0x71, 0xe7, 0x9d, 0xef, 0x9b, 0x9d, 0xf9, 0xe6, 0x67, 0x0d, 0x9b, 0x43, 0x2f, 0xe2, 0x7e,
|
||||
0x18, 0x10, 0x2a, 0x3a, 0x11, 0x67, 0x82, 0x21, 0xcc, 0x2d, 0xf6, 0xee, 0x88, 0xb1, 0x51, 0x48,
|
||||
0xf6, 0x25, 0x32, 0x98, 0x7c, 0xdc, 0xf7, 0x68, 0x92, 0xd1, 0xec, 0x1b, 0x8b, 0x10, 0x19, 0x47,
|
||||
0x22, 0x07, 0xf7, 0x16, 0xc1, 0xe1, 0x84, 0x7b, 0x22, 0x60, 0x34, 0xc3, 0x9d, 0x1f, 0x06, 0xe0,
|
||||
0x51, 0xc8, 0x26, 0xc3, 0xde, 0x94, 0x50, 0xd1, 0xa3, 0x53, 0x12, 0xb2, 0x88, 0x60, 0x13, 0xcc,
|
||||
0x60, 0x68, 0x19, 0x2d, 0xa3, 0xbd, 0xee, 0x9a, 0xc1, 0x10, 0xb7, 0xa1, 0x16, 0xb3, 0x09, 0xf7,
|
||||
0x89, 0x65, 0x4a, 0x9b, 0x3a, 0x21, 0x42, 0x45, 0x24, 0x11, 0xb1, 0xca, 0xd2, 0x2a, 0xbf, 0xb1,
|
||||
0x05, 0x8d, 0x38, 0x22, 0xfe, 0x3b, 0xc2, 0xe3, 0x80, 0x51, 0xab, 0x22, 0x21, 0xdd, 0x84, 0x6d,
|
||||
0xf8, 0x77, 0xe8, 0x09, 0xef, 0x88, 0x51, 0x41, 0xa8, 0x38, 0x4b, 0x2f, 0xa8, 0x4a, 0xd6, 0xa2,
|
||||
0x19, 0xb7, 0xa0, 0x2a, 0x58, 0x14, 0xf8, 0x56, 0x4d, 0xe2, 0xd9, 0x01, 0xdb, 0x50, 0x49, 0x89,
|
||||
0xd6, 0x5a, 0xcb, 0x68, 0x37, 0xba, 0x5b, 0x9d, 0x4c, 0x63, 0x27, 0xd7, 0xd8, 0x79, 0x4e, 0x13,
|
||||
0x57, 0x32, 0x9c, 0x9f, 0x06, 0x6c, 0xbd, 0x08, 0xe8, 0x30, 0xa0, 0xa3, 0xcb, 0x02, 0x11, 0x2a,
|
||||
0xd4, 0x1b, 0x13, 0x25, 0x51, 0x7e, 0xcf, 0xae, 0x35, 0xaf, 0xbb, 0x16, 0x5f, 0x43, 0x7d, 0x4c,
|
||||
0x84, 0x27, 0xd9, 0xe5, 0x56, 0xb9, 0xdd, 0xe8, 0x76, 0x3a, 0x5a, 0xfb, 0x96, 0x45, 0xec, 0xbc,
|
||||
0x51, 0x0e, 0x3d, 0x2a, 0x78, 0xe2, 0xce, 0xfc, 0xed, 0x03, 0xf8, 0xe7, 0x12, 0x84, 0x9b, 0x50,
|
||||
0xbe, 0x20, 0x89, 0xca, 0x2c, 0xfd, 0x4c, 0xab, 0x30, 0xf5, 0xc2, 0x49, 0x5e, 0xfc, 0xec, 0xf0,
|
||||
0xcc, 0x7c, 0x62, 0x38, 0x5f, 0x0d, 0xd8, 0x51, 0xd1, 0x5c, 0x12, 0x47, 0x8c, 0xc6, 0x64, 0x26,
|
||||
0x31, 0x97, 0x63, 0x5c, 0x2b, 0xa7, 0x09, 0xa6, 0x60, 0x96, 0xd9, 0x2a, 0xa7, 0xdd, 0x16, 0x0c,
|
||||
0xef, 0x42, 0x35, 0x16, 0x9e, 0x20, 0x4a, 0xdb, 0x7f, 0xba, 0xb6, 0xd3, 0x14, 0x70, 0x33, 0x3c,
|
||||
0x6d, 0xb5, 0xcf, 0xa8, 0x3f, 0xe1, 0x9c, 0x50, 0x3f, 0xc9, 0x5b, 0xad, 0x99, 0x9c, 0xef, 0x06,
|
||||
0x34, 0x5f, 0xd1, 0x29, 0xbb, 0x98, 0xe7, 0xb5, 0x0d, 0xb5, 0x31, 0x11, 0xe7, 0x2c, 0x9f, 0x2f,
|
||||
0x75, 0xfa, 0x8d, 0xf2, 0x1f, 0x17, 0xca, 0xdf, 0xd6, 0x53, 0xbc, 0x1c, 0xef, 0xef, 0x14, 0xfe,
|
||||
0x31, 0xdc, 0x3a, 0x21, 0xe2, 0x2c, 0x1d, 0xc7, 0xd3, 0xc9, 0x20, 0xf6, 0x79, 0x10, 0xa5, 0x5b,
|
||||
0x15, 0xeb, 0x2a, 0xe5, 0xb0, 0xc6, 0x96, 0x21, 0xeb, 0xaa, 0x4e, 0xce, 0x21, 0xb4, 0x4e, 0x88,
|
||||
0x50, 0x3d, 0x8b, 0x97, 0xfb, 0xda, 0x50, 0x1f, 0x28, 0x82, 0xf2, 0x9e, 0x9d, 0x9d, 0xcf, 0x26,
|
||||
0x54, 0x65, 0x0f, 0x96, 0xa4, 0x7b, 0x5f, 0x4f, 0x77, 0x55, 0x09, 0x33, 0x4a, 0xba, 0x00, 0x44,
|
||||
0x78, 0xa3, 0x7c, 0x73, 0xd3, 0x6f, 0x3c, 0xd0, 0xea, 0x5a, 0x91, 0x75, 0xbd, 0x5d, 0x68, 0xfd,
|
||||
0xaa, 0x72, 0x62, 0x17, 0xd6, 0x58, 0xa6, 0x43, 0x2e, 0x73, 0xa3, 0x6b, 0x15, 0x7c, 0xfb, 0x19,
|
||||
0xee, 0xe6, 0xc4, 0x3f, 0x6b, 0xc1, 0x17, 0x03, 0x36, 0xf4, 0x6b, 0x17, 0xa7, 0xd1, 0x28, 0x4c,
|
||||
0xa3, 0x62, 0xc4, 0x41, 0x2c, 0x24, 0xc3, 0x9c, 0x31, 0x72, 0x13, 0x3e, 0x85, 0x06, 0x27, 0x82,
|
||||
0x27, 0x6f, 0x59, 0x18, 0xf8, 0x89, 0xac, 0x4e, 0xa3, 0xbb, 0xa3, 0x2b, 0x71, 0xe7, 0xb0, 0xab,
|
||||
0x73, 0x9d, 0x4f, 0xd0, 0xd0, 0x30, 0xbc, 0x09, 0xeb, 0xe2, 0x9c, 0x93, 0xf8, 0x9c, 0x85, 0xd9,
|
||||
0xa4, 0x57, 0xdd, 0xb9, 0x01, 0x2d, 0x58, 0x8b, 0x3c, 0x21, 0x08, 0xa7, 0x2a, 0x8b, 0xfc, 0x88,
|
||||
0x8f, 0xa0, 0x1e, 0x50, 0x41, 0xf8, 0xd4, 0x0b, 0x55, 0xf8, 0xdd, 0x42, 0x1f, 0x8f, 0xd5, 0x23,
|
||||
0xee, 0xce, 0xa8, 0xdd, 0x6f, 0x65, 0x80, 0x63, 0x2f, 0xe2, 0x47, 0x32, 0x4b, 0x3c, 0x84, 0x7a,
|
||||
0x9f, 0x66, 0x8b, 0x80, 0xf6, 0xea, 0xe5, 0xb0, 0x97, 0xce, 0x88, 0x53, 0xc2, 0x0f, 0xf0, 0xff,
|
||||
0xd2, 0xf9, 0xc6, 0xed, 0x82, 0x43, 0x2f, 0xfd, 0xdd, 0xd8, 0xf7, 0xf4, 0x20, 0x57, 0xae, 0x86,
|
||||
0x53, 0xc2, 0x01, 0x58, 0xab, 0x96, 0x60, 0x65, 0x80, 0x07, 0x0b, 0x01, 0xae, 0x5c, 0x21, 0xa7,
|
||||
0x84, 0xef, 0xa1, 0xd9, 0xa7, 0xfa, 0x4b, 0x8c, 0xad, 0xeb, 0xde, 0x68, 0xfb, 0xce, 0x12, 0xc6,
|
||||
0xe2, 0xbb, 0xea, 0x94, 0xf0, 0x25, 0x6c, 0xf4, 0xa9, 0x14, 0x98, 0x5d, 0xbc, 0xa7, 0xbb, 0x15,
|
||||
0xff, 0xa6, 0xf6, 0x0a, 0x49, 0x4e, 0x69, 0x50, 0x93, 0x96, 0x87, 0xbf, 0x02, 0x00, 0x00, 0xff,
|
||||
0xff, 0x08, 0x99, 0x1b, 0xe5, 0xfd, 0x07, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// DaprClientClient is the client API for DaprClient service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type DaprClientClient interface {
|
||||
OnInvoke(ctx context.Context, in *InvokeEnvelope, opts ...grpc.CallOption) (*any.Any, error)
|
||||
GetTopicSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetTopicSubscriptionsEnvelope, error)
|
||||
GetBindingsSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetBindingsSubscriptionsEnvelope, error)
|
||||
OnBindingEvent(ctx context.Context, in *BindingEventEnvelope, opts ...grpc.CallOption) (*BindingResponseEnvelope, error)
|
||||
OnTopicEvent(ctx context.Context, in *CloudEventEnvelope, opts ...grpc.CallOption) (*empty.Empty, error)
|
||||
}
|
||||
|
||||
type daprClientClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewDaprClientClient(cc *grpc.ClientConn) DaprClientClient {
|
||||
return &daprClientClient{cc}
|
||||
}
|
||||
|
||||
func (c *daprClientClient) OnInvoke(ctx context.Context, in *InvokeEnvelope, opts ...grpc.CallOption) (*any.Any, error) {
|
||||
out := new(any.Any)
|
||||
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/OnInvoke", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daprClientClient) GetTopicSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetTopicSubscriptionsEnvelope, error) {
|
||||
out := new(GetTopicSubscriptionsEnvelope)
|
||||
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/GetTopicSubscriptions", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daprClientClient) GetBindingsSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*GetBindingsSubscriptionsEnvelope, error) {
|
||||
out := new(GetBindingsSubscriptionsEnvelope)
|
||||
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/GetBindingsSubscriptions", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daprClientClient) OnBindingEvent(ctx context.Context, in *BindingEventEnvelope, opts ...grpc.CallOption) (*BindingResponseEnvelope, error) {
|
||||
out := new(BindingResponseEnvelope)
|
||||
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/OnBindingEvent", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daprClientClient) OnTopicEvent(ctx context.Context, in *CloudEventEnvelope, opts ...grpc.CallOption) (*empty.Empty, error) {
|
||||
out := new(empty.Empty)
|
||||
err := c.cc.Invoke(ctx, "/daprclient.DaprClient/OnTopicEvent", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DaprClientServer is the server API for DaprClient service.
|
||||
type DaprClientServer interface {
|
||||
OnInvoke(context.Context, *InvokeEnvelope) (*any.Any, error)
|
||||
GetTopicSubscriptions(context.Context, *empty.Empty) (*GetTopicSubscriptionsEnvelope, error)
|
||||
GetBindingsSubscriptions(context.Context, *empty.Empty) (*GetBindingsSubscriptionsEnvelope, error)
|
||||
OnBindingEvent(context.Context, *BindingEventEnvelope) (*BindingResponseEnvelope, error)
|
||||
OnTopicEvent(context.Context, *CloudEventEnvelope) (*empty.Empty, error)
|
||||
}
|
||||
|
||||
func RegisterDaprClientServer(s *grpc.Server, srv DaprClientServer) {
|
||||
s.RegisterService(&_DaprClient_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _DaprClient_OnInvoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(InvokeEnvelope)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaprClientServer).OnInvoke(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/daprclient.DaprClient/OnInvoke",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaprClientServer).OnInvoke(ctx, req.(*InvokeEnvelope))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DaprClient_GetTopicSubscriptions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(empty.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaprClientServer).GetTopicSubscriptions(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/daprclient.DaprClient/GetTopicSubscriptions",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaprClientServer).GetTopicSubscriptions(ctx, req.(*empty.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DaprClient_GetBindingsSubscriptions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(empty.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaprClientServer).GetBindingsSubscriptions(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/daprclient.DaprClient/GetBindingsSubscriptions",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaprClientServer).GetBindingsSubscriptions(ctx, req.(*empty.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DaprClient_OnBindingEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(BindingEventEnvelope)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaprClientServer).OnBindingEvent(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/daprclient.DaprClient/OnBindingEvent",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaprClientServer).OnBindingEvent(ctx, req.(*BindingEventEnvelope))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DaprClient_OnTopicEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CloudEventEnvelope)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaprClientServer).OnTopicEvent(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/daprclient.DaprClient/OnTopicEvent",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaprClientServer).OnTopicEvent(ctx, req.(*CloudEventEnvelope))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _DaprClient_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "daprclient.DaprClient",
|
||||
HandlerType: (*DaprClientServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "OnInvoke",
|
||||
Handler: _DaprClient_OnInvoke_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetTopicSubscriptions",
|
||||
Handler: _DaprClient_GetTopicSubscriptions_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetBindingsSubscriptions",
|
||||
Handler: _DaprClient_GetBindingsSubscriptions_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "OnBindingEvent",
|
||||
Handler: _DaprClient_OnBindingEvent_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "OnTopicEvent",
|
||||
Handler: _DaprClient_OnTopicEvent_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "daprclient.proto",
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package daprexamples;
|
||||
|
||||
option java_outer_classname = "DaprExamplesProtos";
|
||||
option java_package = "io.dapr.examples";
|
||||
|
||||
// User Code definitions
|
||||
service HelloWorld {
|
||||
rpc Say (SayRequest) returns (SayResponse) {}
|
||||
}
|
||||
|
||||
message SayRequest {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
message SayResponse {
|
||||
string timestamp = 1;
|
||||
}
|
Loading…
Reference in New Issue