mirror of https://github.com/dapr/java-sdk.git
fix readme
This commit is contained in:
parent
37fa7d9542
commit
06116e223d
16
README.md
16
README.md
|
|
@ -5,15 +5,25 @@ This is the Dapr SDK for Java, based on the auto-generated proto client.<br>
|
||||||
For more info on Dapr and gRPC, visit [this link](https://github.com/dapr/docs/tree/master/howto/create-grpc-app).
|
For more info on Dapr and gRPC, visit [this link](https://github.com/dapr/docs/tree/master/howto/create-grpc-app).
|
||||||
|
|
||||||
### Installing
|
### Installing
|
||||||
|
|
||||||
|
The client will generate gRPC Client and Protobuf classes during build.
|
||||||
|
|
||||||
|
Make sure to clone this repository including the submodules:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone --recurse-submodules https://github.com/dapr/java-sdk.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Then head over to build the Maven project:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# make sure you are in the `java-sdk` directory.
|
# make sure you are in the `java-sdk` directory.
|
||||||
mvn package install
|
mvn install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running an example
|
### Running an example
|
||||||
```sh
|
```sh
|
||||||
cd examples/
|
cd examples/
|
||||||
mvn compile
|
|
||||||
dapr run --protocol grpc --grpc-port 50001 -- mvn exec:java -Dexec.mainClass=io.dapr.examples.Example
|
dapr run --protocol grpc --grpc-port 50001 -- mvn exec:java -Dexec.mainClass=io.dapr.examples.Example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -30,7 +40,7 @@ https://maven.apache.org/plugins/maven-deploy-plugin
|
||||||
|
|
||||||
https://help.sonatype.com/repomanager3/user-interface/uploading-components
|
https://help.sonatype.com/repomanager3/user-interface/uploading-components
|
||||||
|
|
||||||
### Releasing with Maven
|
### Maven Module version management
|
||||||
To increase the version of all modules and pom files, run the following commands:
|
To increase the version of all modules and pom files, run the following commands:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package io.dapr.examples;
|
package io.dapr.examples;
|
||||||
|
|
||||||
|
import static java.lang.System.out;
|
||||||
|
|
||||||
import com.google.protobuf.Any;
|
import com.google.protobuf.Any;
|
||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
|
|
||||||
|
|
@ -27,19 +29,19 @@ public class Example {
|
||||||
|
|
||||||
var data = Any.newBuilder().setValue(ByteString.copyFromUtf8("foo")).build();
|
var data = Any.newBuilder().setValue(ByteString.copyFromUtf8("foo")).build();
|
||||||
client.publishEvent(PublishEventEnvelope.newBuilder().setTopic("foo").setData(data).build());
|
client.publishEvent(PublishEventEnvelope.newBuilder().setTopic("foo").setData(data).build());
|
||||||
System.out.println("Published!");
|
out.println("Published!");
|
||||||
|
|
||||||
var key = "mykey";
|
var key = "mykey";
|
||||||
var req = StateRequest.newBuilder().setKey(key)
|
var req = StateRequest.newBuilder().setKey(key)
|
||||||
.setValue(Any.newBuilder().setValue(ByteString.copyFromUtf8("my value")).build()).build();
|
.setValue(Any.newBuilder().setValue(ByteString.copyFromUtf8("my value")).build()).build();
|
||||||
var state = SaveStateEnvelope.newBuilder().addRequests(req).build();
|
var state = SaveStateEnvelope.newBuilder().addRequests(req).build();
|
||||||
client.saveState(state);
|
client.saveState(state);
|
||||||
System.out.println("Saved!");
|
out.println("Saved!");
|
||||||
|
|
||||||
var get = client.getState(GetStateEnvelope.newBuilder().setKey(key).build());
|
var get = client.getState(GetStateEnvelope.newBuilder().setKey(key).build());
|
||||||
System.out.println("Got: " + get.getData().getValue().toStringUtf8());
|
out.println("Got: " + get.getData().getValue().toStringUtf8());
|
||||||
|
|
||||||
client.deleteState(DeleteStateEnvelope.newBuilder().setKey(key).build());
|
client.deleteState(DeleteStateEnvelope.newBuilder().setKey(key).build());
|
||||||
System.out.println("Deleted!");
|
out.println("Deleted!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ import com.sun.net.httpserver.HttpServer;
|
||||||
import com.sun.net.httpserver.HttpExchange;
|
import com.sun.net.httpserver.HttpExchange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OrderManager
|
* OrderManager web app.
|
||||||
|
*
|
||||||
|
* Based on the helloworld Node.js example in https://github.com/dapr/samples/blob/master/1.hello-world/app.js
|
||||||
*/
|
*/
|
||||||
public class OrderManager {
|
public class OrderManager {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue