* fix readme.md

* fix readme.md

* fix readme.md

* fix readme.md

* fix grpc readme.md

* fix grpc readme.md

* fix grpc readme.md

* fix readme.md

Co-authored-by: Yaron Schneider <yaronsc@microsoft.com>
This commit is contained in:
Yao Yao 2021-04-16 02:43:27 +08:00 committed by GitHub
parent d5be5422b4
commit ab924fba7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -84,7 +84,9 @@ For more granular control, the Dapr Go client exposes `SetStateItem` type, which
```go
item1 := &dapr.SetStateItem{
Key: "key1",
Etag: "2",
Etag: &ETag{
Value: "1",
},
Metadata: map[string]string{
"created-on": time.Now().UTC().String(),
},
@ -105,20 +107,22 @@ item2 := &dapr.SetStateItem{
item3 := &dapr.SetStateItem{
Key: "key3",
Etag: "1",
Etag: &dapr.ETag{
Value: "1",
},
Value: []byte("hello again"),
}
if err := client.SaveStateItems(ctx, store, item1, item2, item3); err != nil {
if err := client.SaveBulkState(ctx, store, item1, item2, item3); err != nil {
panic(err)
}
```
Similarly, `GetBulkItems` method provides a way to retrieve multiple state items in a single operation:
Similarly, `GetBulkState` method provides a way to retrieve multiple state items in a single operation:
```go
keys := []string{"key1", "key2", "key3"}
items, err := client.GetBulkItems(ctx, store, keys, 100)
items, err := client.GetBulkState(ctx, store, keys, nil,100)
```
And the `ExecuteStateTransaction` method to execute multiple `upsert` or `delete` operations transactionally.
@ -160,7 +164,7 @@ if err := client.PublishEvent(ctx, "component-name", "topic-name", data); err !=
To invoke a specific method on another service running with Dapr sidecar, the Dapr client provides two options. To invoke a service without any data:
```go
resp, err = client.InvokeMethod(ctx, "app-id", "method-name")
resp, err := client.InvokeMethod(ctx, "app-id", "method-name", "post")
```
And to invoke a service with data:
@ -171,7 +175,7 @@ content := &dapr.DataContent{
Data: []byte(`{ "id": "a123", "value": "demo", "valid": true }`),
}
resp, err := client.InvokeMethodWithContent(ctx, "app-id", "method-name", content)
resp, err = client.InvokeMethodWithContent(ctx, "app-id", "method-name", "post", content)
```
##### Bindings

View File

@ -24,10 +24,7 @@ list, err := net.Listen("tcp", "localhost:0")
if err != nil {
log.Fatalf("gRPC listener creation failed: %s", err)
}
s, err := daprd.NewService(list)
if err != nil {
log.Fatalf("failed to start the server: %v", err)
}
s := daprd.NewServiceWithListener(list)
```
Once you create a service instance, you can "attach" to that service any number of event, binding, and service invocation logic handlers as shown below. Onces the logic is defined, you are ready to start the service: