mirror of https://github.com/dapr/docs.git
Merge pull request #2567 from hhunter-ms/python_example
add back python example
This commit is contained in:
commit
566302b05e
|
@ -212,7 +212,40 @@ message SubscribeConfigurationRequest {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Using this method, you can subscribe to changes in specific keys for a given configuration store. gRPC streaming varies widely based on language. [See the gRPC examples](https://grpc.io/docs/languages/) for usage.
|
Using this method, you can subscribe to changes in specific keys for a given configuration store. gRPC streaming varies widely based on language - see the [gRPC examples here](https://grpc.io/docs/languages/) for usage.
|
||||||
|
|
||||||
|
Below are the examples in sdks:
|
||||||
|
|
||||||
|
{{< tabs Python>}}
|
||||||
|
|
||||||
|
{{% codetab %}}
|
||||||
|
```python
|
||||||
|
#dependencies
|
||||||
|
import asyncio
|
||||||
|
from dapr.clients import DaprClient
|
||||||
|
#code
|
||||||
|
async def executeConfiguration():
|
||||||
|
with DaprClient() as d:
|
||||||
|
CONFIG_STORE_NAME = 'configstore'
|
||||||
|
key = 'orderId'
|
||||||
|
# Subscribe to configuration by key.
|
||||||
|
configuration = await d.subscribe_configuration(store_name=CONFIG_STORE_NAME, keys=[key], config_metadata={})
|
||||||
|
if configuration != None:
|
||||||
|
items = configuration.get_items()
|
||||||
|
for item in items:
|
||||||
|
print(f"Subscribe key={item.key} value={item.value} version={item.version}", flush=True)
|
||||||
|
else:
|
||||||
|
print("Nothing yet")
|
||||||
|
asyncio.run(executeConfiguration())
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dapr run --app-id orderprocessing --components-path components/ -- python3 OrderProcessingService.py
|
||||||
|
```
|
||||||
|
|
||||||
|
{{% /codetab %}}
|
||||||
|
|
||||||
|
{{< /tabs >}}
|
||||||
|
|
||||||
#### Stop watching configuration items
|
#### Stop watching configuration items
|
||||||
|
|
||||||
|
|
|
@ -508,7 +508,7 @@ For this example, you will need:
|
||||||
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
||||||
- Java JDK 11 (or greater):
|
- Java JDK 11 (or greater):
|
||||||
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
||||||
- [OpenJDK](https://jdk.java.net/13/)
|
- [OpenJDK](https://jdk.java.net/projects/jdk/13/)
|
||||||
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
||||||
<!-- IGNORE_LINKS -->
|
<!-- IGNORE_LINKS -->
|
||||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||||
|
|
|
@ -352,7 +352,7 @@ For this example, you will need:
|
||||||
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
||||||
- Java JDK 11 (or greater):
|
- Java JDK 11 (or greater):
|
||||||
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
||||||
- [OpenJDK](https://jdk.java.net/13/)
|
- [OpenJDK](https://jdk.java.net/projects/jdk/13/)
|
||||||
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
||||||
<!-- IGNORE_LINKS -->
|
<!-- IGNORE_LINKS -->
|
||||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||||
|
|
|
@ -388,7 +388,7 @@ For this example, you will need:
|
||||||
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
||||||
- Java JDK 11 (or greater):
|
- Java JDK 11 (or greater):
|
||||||
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
||||||
- [OpenJDK](https://jdk.java.net/13/)
|
- [OpenJDK](https://jdk.java.net/projects/jdk/13/)
|
||||||
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
||||||
<!-- IGNORE_LINKS -->
|
<!-- IGNORE_LINKS -->
|
||||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||||
|
|
|
@ -386,7 +386,7 @@ For this example, you will need:
|
||||||
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
|
||||||
- Java JDK 11 (or greater):
|
- Java JDK 11 (or greater):
|
||||||
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
|
||||||
- [OpenJDK](https://jdk.java.net/13/)
|
- [OpenJDK](https://jdk.java.net/projects/jdk/13/)
|
||||||
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
|
||||||
<!-- IGNORE_LINKS -->
|
<!-- IGNORE_LINKS -->
|
||||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||||
|
|
Loading…
Reference in New Issue