From 81023636f9b64f9e5cb0da93bf57813c865fef67 Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Wed, 8 Jan 2020 15:25:16 -0800 Subject: [PATCH] Fixing documentation about state key delim. (#279) Co-authored-by: Yaron Schneider --- concepts/state-management/state-management.md | 4 ++-- howto/query-state-store/query-cosmosdb-store.md | 10 +++++----- howto/query-state-store/query-redis-store.md | 12 ++++++------ reference/api/state.md | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/concepts/state-management/state-management.md b/concepts/state-management/state-management.md index b03d596b7..756754684 100644 --- a/concepts/state-management/state-management.md +++ b/concepts/state-management/state-management.md @@ -68,13 +68,13 @@ KEYS "myApp*" If the data store supports SQL queries, you can query an actor's state using SQL queries. For example use: ```sql -SELECT * FROM StateTable WHERE Id='---' +SELECT * FROM StateTable WHERE Id='__delim____delim____delim__' ``` You can also perform aggregate queries across actor instances, avoiding the common turn-based concurrency limitations of actor frameworks. For example, to calculate the average temperature of all thermometer actors, use: ```sql -SELECT AVG(value) FROM StateTable WHERE Id LIKE '--*-temperature' +SELECT AVG(value) FROM StateTable WHERE Id LIKE '__delim____delim__*__delim__temperature' ``` > **NOTE:** Direct queries of the state store are not governed by Dapr concurrency control, since you are not calling through the Dapr runtime. What you see are snapshots of committed data which are acceptable for read-only queries across multiple actors, however writes should be done via the actor instances. diff --git a/howto/query-state-store/query-cosmosdb-store.md b/howto/query-state-store/query-cosmosdb-store.md index c129116a7..744e9e783 100644 --- a/howto/query-state-store/query-cosmosdb-store.md +++ b/howto/query-state-store/query-cosmosdb-store.md @@ -15,7 +15,7 @@ The easiest way to connect to your Cosmos DB instance is to use the Data Explore To get all state keys associated with application "myapp", use the query: ```sql -SELECT * FROM states WHERE CONTAINS(states.id, 'myapp-') +SELECT * FROM states WHERE CONTAINS(states.id, 'myapp__delim__') ``` The above query returns all documents with id containing "myapp-", which is the prefix of the state keys. @@ -25,25 +25,25 @@ The above query returns all documents with id containing "myapp-", which is the To get the state data by a key "balance" for the application "myapp", use the query: ```bash -SELECT * FROM states WHERE states.id = 'myapp-balance' +SELECT * FROM states WHERE states.id = 'myapp__delim__balance' ``` Then, read the **value** field of the returned document. To get the state version/ETag, use the command: ```bash -SELECT states._etag FROM states WHERE states.id = 'myapp-balance' +SELECT states._etag FROM states WHERE states.id = 'myapp__delim__balance' ``` ## 4. Read actor state To get all the state keys associated with an actor with the instance ID "leroy" of actor type "cat" belonging to the application with ID "mypets", use the command: ```bash -SELECT * FROM states WHERE CONTAINS(states.id, 'mypets-cat-leroy-') +SELECT * FROM states WHERE CONTAINS(states.id, 'mypets__delim__cat__delim__leroy__delim__') ``` And to get a specific actor state such as "food", use the command: ```bash -SELECT * FROM states WHERE states.id = 'mypets-cat-leroy-food' +SELECT * FROM states WHERE states.id = 'mypets__delim__cat__delim__leroy__delim__food' ``` > **WARNING:** You should not manually update or delete states in the store. All writes and delete operations should be done via the Dapr runtime. diff --git a/howto/query-state-store/query-redis-store.md b/howto/query-state-store/query-redis-store.md index e3bc857dc..8bcae4c21 100644 --- a/howto/query-state-store/query-redis-store.md +++ b/howto/query-state-store/query-redis-store.md @@ -21,8 +21,8 @@ KEYS myapp* The above command returns a list of existing keys, for example: ```bash -1) "myapp-balance" -2) "myapp-amount" +1) "myapp__delim__balance" +2) "myapp__delim__amount" ``` ## 3. Get specific state data @@ -32,24 +32,24 @@ Dapr saves state values as hash values. Each hash value contains a "data" field, For example, to get the state data by a key "balance" for the application "myapp", use the command: ```bash -HGET myapp-balance data +HGET myapp__delim__balance data ``` To get the state version/ETag, use the command: ```bash -HGET myapp-balance version +HGET myapp__delim__balance version ``` ## 4. Read actor state To get all the state keys associated with an actor with the instance ID "leroy" of actor type "cat" belonging to the application with ID "mypets", use the command: ```bash -KEYS mypets-cat-leroy* +KEYS mypets__delim__cat__delim__leroy* ``` And to get a specific actor state such as "food", use the command: ```bash -HGET mypets-cat-leroy-food value +HGET mypets__delim__cat__delim__leroy__delim__food value ``` > **WARNING:** You should not manually update or delete states in the store. All writes and delete operations should be done via the Dapr runtime. diff --git a/reference/api/state.md b/reference/api/state.md index 1c4d056bb..0f4ac4227 100644 --- a/reference/api/state.md +++ b/reference/api/state.md @@ -28,11 +28,11 @@ the ```spec/metadata``` section is an open key value pair metadata that allows a ## Key scheme Dapr state stores are key/value stores. To ensure data compatibility, Dapr requires these data stores follow a fixed key scheme. For general states, the key format is: ```bash -- +__delim__ ``` For Actor states, the key format is: ```bash ---- +__delim____delim____delim__ ``` @@ -194,8 +194,8 @@ curl -X "DELETE" http://localhost:3500/v1.0/state/planet -H "ETag: xxxxxxx" A Dapr-compatible state store shall use the following key scheme: -* *\-\* key format for general states -* *\-\-\-\* key format for Actor states. +* *\__delim__\* key format for general states +* *\__delim__\__delim__\__delim__\* key format for Actor states. ### Concurrency Dapr uses Optimized Concurrency Control (OCC) with ETags. Dapr makes optional the following requirements on state stores: