[state management] Update docs around transactional operations (#2372)

* clarify transactional operations in docs

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

* Added some more details for clarity

* updates per Mark

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

* remove en from link

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

* ignore links attempt

Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com>

Co-authored-by: Mark Fussell <markfussell@gmail.com>
This commit is contained in:
Hannah Hunter 2022-04-15 18:38:23 -05:00 committed by GitHub
parent cc8a2770ed
commit 89eb035461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 11 deletions

View File

@ -46,4 +46,6 @@ git reset --hard
```
## Related links
- [GitHub documentation](https://docs.github.com/en/github/developing-online-with-codespaces/about-codespaces)
<!-- IGNORE_LINKS -->
- [GitHub documentation](https://docs.github.com/github/developing-online-with-codespaces/about-codespaces)
<!-- END_IGNORE -->

View File

@ -66,11 +66,17 @@ With the HTTP API, you can set content type via URL query parameter `metadata.co
With the gRPC API, you can set content type by adding key/value pair `"contentType" : <content type>` to the request metadata.
### Bulk operations
### Multiple operations
Dapr supports two types of bulk operations: **bulk** or **multi**. You can group several requests of the same type into a bulk (or a batch). Dapr submits requests in bulk operations as individual requests to the underlying data store. In other words, bulk operations are not transactional. On the other hand, you can group requests of different types into a multi-operation, which is then handled as an atomic transaction.
Dapr supports two types of mult-read or multi-write operations: **bulk** or **transactional**. Read the [API reference]({{< ref state_api.md >}}) to learn how use bulk and multi options.
Read the [API reference]({{< ref state_api.md >}}) to learn how use bulk and multi options.
#### Bulk read operations
You can group multiple read requests into a bulk (or batch) operation. In the bulk operation, Dapr submits the read requests as individual requests to the underlying data store, and returns them as a single result.
#### Transactional operations
You can group write, update and delete operations into a request, which are then handled as an atomic transaction. The request will succeed or fail as a transactional set of operations.
### State encryption
Dapr supports automatic client encryption of application state with support for key rotations. This is supported on all Dapr state stores. For more info, read the [How-To: Encrypt application state]({{< ref howto-encrypt-state.md >}}) topic.

View File

@ -443,9 +443,9 @@ POST http://localhost:3500/v1.0-alpha1/state/myStore/query?metadata.partitionKey
## State transactions
Persists the changes to the state store as a multi-item transaction.
Persists the changes to the state store as a [transactional operation]({{< ref "state-management-overview.md#transactional-operations" >}}).
> This operation depends on a state store component that supports multi-item transactions.
> This API depends on a state store component that supports transactions.
Refer to the [state store component spec]({{< ref "supported-state-stores.md" >}}) for a full, current list of state stores that support transactions.
@ -481,20 +481,28 @@ POST http://localhost:3500/v1.0/state/myStore/transaction?metadata.contentType=a
Field | Description
---- | -----------
`operations` | A JSON array of state operation
`metadata` | (optional) The metadata for transaction that applies to all operations
`operations` | A JSON array of state `operation`
`metadata` | (optional) The `metadata` for the transaction that applies to all operations
Each state operation is comprised with the following fields:
All transactional databases implement the following required operations:
Field | Description
Operation | Description
--------- | -----------
`upsert` | Adds or updates the value
`delete` | Deletes the value
Each operation has an associated `request` that is comprised of the following fields:
Request | Description
---- | -----------
`key` | State key
`value` | State value, which can be any byte array
`etag` | (optional) State ETag
`metadata` | (optional) Additional key-value pairs to be passed to the state store
`metadata` | (optional) Additional key-value pairs to be passed to the state store that apply for this operation
`options` | (optional) State operation options; see [state operation options](#optional-behaviors)
#### Examples
The example below shows an `upsert` operation for `key1` and a `delete` operation for `key2`. This is applied to the partition named 'planet' in the state store. Both operations either succeed or fail in the transaction.
```shell
curl -X POST http://localhost:3500/v1.0/state/starwars/transaction \