Merge branch 'v1.10' of https://github.com/dapr/docs into issue_2873

This commit is contained in:
Hannah Hunter 2023-01-27 19:01:26 -06:00
commit 2a7e2bc3b1
25 changed files with 815 additions and 92 deletions

View File

@ -6,17 +6,40 @@ weight: 1000
description: "Overview of the configuration API building block"
---
## Introduction
Consuming application configuration is a common task when writing applications. Frequently, configuration stores are used to manage this configuration data. A configuration item is often dynamic in nature and tightly coupled to the needs of the application that consumes it.
Consuming application configuration is a common task when writing applications and frequently configuration stores are used to manage this configuration data. A configuration item is often dynamic in nature and is tightly coupled to the needs of the application that consumes it. For example, common uses for application configuration include names of secrets, different identifiers, partition or consumer IDs, names of databases to connect to etc. These configuration items are typically stored as key/value items in a state store or database. Application configuration can be changed by either developers or operators at runtime and the developer needs to be notified of these changes in order to take the required action and load the new configuration. Also configuration data is typically read only from the application API perspective, with updates to the configuration store made through operator tooling. Dapr's configuration API allows developers to consume configuration items that are returned as read only key/value pairs and subscribe to changes whenever a configuration item changes.
For example, application configuration can include:
- Names of secrets
- Different identifiers
- Partition or consumer IDs
- Names of databases to connect to, etc
Usually, configuration items are stored as key/value items in a state store or database. Developers or operators can change application configuration at runtime in the configuration store. Once changes are made, a service is notified to load the new configuration.
Configuration data is read-only from the application API perspective, with updates to the configuration store made through operator tooling. With Dapr's configuration API, you can:
- Consume configuration items that are returned as read-only key/value pairs
- Subscribe to changes whenever a configuration item changes
<img src="/images/configuration-api-overview.png" width=900>
It is worth noting that this configuration API should not be confused with the [Dapr sidecar and control plane configuration]({{<ref "configuration-overview">}}) which is used to set policies and settings on instances of Dapr sidecars or the installed Dapr control plane.
{{% alert title="Note" color="primary" %}}
The Configuration API should not be confused with the [Dapr sidecar and control plane configuration]({{< ref "configuration-overview" >}}), which is used to set policies and settings on Dapr sidecar instances or the installed Dapr control plane.
{{% /alert %}}
*This API is currently in `Alpha` state*
## Try out configuration
### Quickstart
Want to put the Dapr configuration API to the test? Walk through the following quickstart to see the configuration API in action:
| Quickstart | Description |
| ---------- | ----------- |
| [Configuration quickstart]({{< ref configuration-quickstart.md >}}) | Get configuration items or subscribe to configuration changes using the configuration API. |
### Start using the configuration API directly in your app
Want to skip the quickstarts? Not a problem. You can try out the configuration building block directly in your application to read and manage configuration data. After [Dapr is installed]({{< ref "getting-started/_index.md" >}}), you can begin using the configuration API starting with [the configuration how-to guide]({{< ref howto-manage-configuration.md >}}).
## Features
## Next steps
Follow these guides on:

View File

@ -8,12 +8,13 @@ description: "Learn how to get application configuration and subscribe for chang
This example uses the Redis configuration store component to demonstrate how to retrieve a configuration item.
<img src="/images/building-block-configuration-example.png" width=1000 alt="Diagram showing get configuration of example service">
{{% alert title="Note" color="primary" %}}
This API is currently in `Alpha` state and only available on gRPC. An HTTP1.1 supported version with this URL syntax `/v1.0/configuration` will be available before the API is certified into `Stable` state.
If you haven't already, [try out the configuration quickstart]({{< ref configuration-quickstart.md >}}) for a quick walk-through on how to use the configuration API.
{{% /alert %}}
<img src="/images/building-block-configuration-example.png" width=1000 alt="Diagram showing get configuration of example service">
## Create a configuration item in store
@ -68,7 +69,7 @@ spec:
## Retrieve Configuration Items
### Get configuration items using Dapr SDKs
{{< tabs Dotnet Java Python>}}
{{< tabs ".NET" Java Python>}}
{{% codetab %}}

View File

@ -18,7 +18,7 @@ There are two scenarios for how tracing is used:
1. Dapr generates the trace context and you propagate the trace context to another service.
2. You generate the trace context and Dapr propagates the trace context to a service.
### Propogating sequential service calls
### Propagating sequential service calls
Dapr takes care of creating the trace headers. However, when there are more than two services, you're responsible for propagating the trace headers between them. Let's go through the scenarios with examples:
@ -45,7 +45,7 @@ There are no helper methods exposed in Dapr SDKs to propagate and retrieve trace
4. Pub/sub messages
Dapr generates the trace headers in the published message topic. These trace headers are propagated to any services listening on that topic.
### Propogating multiple different service calls
### Propagating multiple different service calls
In the following scenarios, Dapr does some of the work for you and you need to either create or propagate trace headers.
@ -115,4 +115,4 @@ In the gRPC API calls, trace context is passed through `grpc-trace-bin` header.
- [Observability concepts]({{< ref observability-concept.md >}})
- [W3C Trace Context for distributed tracing]({{< ref w3c-tracing-overview >}})
- [W3C Trace Context specification](https://www.w3.org/TR/trace-context/)
- [Observability quickstart](https://github.com/dapr/quickstarts/tree/master/tutorials/observability)
- [Observability quickstart](https://github.com/dapr/quickstarts/tree/master/tutorials/observability)

View File

@ -16,7 +16,7 @@ Even though the state store is a key/value store, the `value` might be a JSON do
## Querying the state
Submit query requests via HTTP POST/PUT or gRPC. The body of the request is the JSON map with 3 _optional_ entries:
Submit query requests via HTTP POST/PUT or gRPC. The body of the request is the JSON map with 3 entries:
- `filter`
- `sort`

View File

@ -188,6 +188,7 @@ Available Commands:
stop Stop Dapr instances and their associated apps. . Supported platforms: Self-hosted
uninstall Uninstall Dapr runtime. Supported platforms: Kubernetes and self-hosted
upgrade Upgrades a Dapr control plane installation in a cluster. Supported platforms: Kubernetes
version Print the Dapr runtime and CLI version
Flags:
-h, --help help for dapr

View File

@ -27,4 +27,5 @@ Hit the ground running with our Dapr quickstarts, complete with code samples aim
| [State Management]({{< ref statemanagement-quickstart.md >}}) | Store a service's data as key/value pairs in supported state stores. |
| [Bindings]({{< ref bindings-quickstart.md >}}) | Work with external systems using input bindings to respond to events and output bindings to call operations. |
| [Secrets Management]({{< ref secrets-quickstart.md >}}) | Securely fetch secrets. |
| [Configuration]({{< ref configuration-quickstart.md >}}) | Get configuration items and subscribe for configuration updates. |
| [Resiliency]({{< ref resiliency >}}) | Define and apply fault-tolerance policies to your Dapr API requests. |

View File

@ -46,7 +46,7 @@ Run the [PostgreSQL instance](https://www.postgresql.org/) locally in a Docker c
In a terminal window, from the root of the Quickstarts clone directory, navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following command to set up the container:
@ -73,7 +73,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
In a new terminal window, navigate to the SDK directory.
```bash
cd quickstarts/bindings/python/sdk/batch
cd bindings/python/sdk/batch
```
Install the dependencies:
@ -137,7 +137,7 @@ Your output binding's `print` statement output:
In a new terminal, verify the same data has been inserted into the database. Navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following to start the interactive Postgres CLI:
@ -253,7 +253,7 @@ Run the [PostgreSQL instance](https://www.postgresql.org/) locally in a Docker c
In a terminal window, from the root of the Quickstarts clone directory, navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following command to set up the container:
@ -280,7 +280,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
In a new terminal window, navigate to the SDK directory.
```bash
cd quickstarts/bindings/javascript/sdk/batch
cd bindings/javascript/sdk/batch
```
Install the dependencies:
@ -339,7 +339,7 @@ Your output binding's `print` statement output:
In a new terminal, verify the same data has been inserted into the database. Navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following to start the interactive Postgres CLI:
@ -455,7 +455,7 @@ Run the [PostgreSQL instance](https://www.postgresql.org/) locally in a Docker c
In a terminal window, from the root of the Quickstarts clone directory, navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following command to set up the container:
@ -482,7 +482,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
In a new terminal window, navigate to the SDK directory.
```bash
cd quickstarts/bindings/csharp/sdk/batch
cd bindings/csharp/sdk/batch
```
Install the dependencies:
@ -543,7 +543,7 @@ Your output binding's `print` statement output:
In a new terminal, verify the same data has been inserted into the database. Navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following to start the interactive Postgres CLI:
@ -662,7 +662,7 @@ Run the [PostgreSQL instance](https://www.postgresql.org/) locally in a Docker c
In a terminal window, from the root of the Quickstarts clone directory, navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following command to set up the container:
@ -689,7 +689,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
In a new terminal window, navigate to the SDK directory.
```bash
cd quickstarts/bindings/java/sdk/batch
cd bindings/java/sdk/batch
```
Install the dependencies:
@ -753,7 +753,7 @@ Your output binding's `print` statement output:
In a new terminal, verify the same data has been inserted into the database. Navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following to start the interactive Postgres CLI:
@ -869,7 +869,7 @@ Run the [PostgreSQL instance](https://www.postgresql.org/) locally in a Docker c
In a terminal window, from the root of the Quickstarts clone directory, navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following command to set up the container:
@ -896,7 +896,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
In a new terminal window, navigate to the SDK directory.
```bash
cd quickstarts/bindings/go/sdk/batch
cd bindings/go/sdk/batch
```
Install the dependencies:
@ -965,7 +965,7 @@ Your output binding's `print` statement output:
In a new terminal, verify the same data has been inserted into the database. Navigate to the `bindings/db` directory.
```bash
cd quickstarts/bindings/db
cd bindings/db
```
Run the following to start the interactive Postgres CLI:

View File

@ -0,0 +1,639 @@
---
type: docs
title: "Quickstart: Configuration"
linkTitle: Configuration
weight: 76
description: Get started with Dapr's Configuration building block
---
Let's take a look at Dapr's [Configuration building block]({{< ref configuration-api-overview.md >}}). A configuration item is often dynamic in nature and tightly coupled to the needs of the application that consumes it. Configuration items are key/value pairs containing configuration data, such as:
- App ids
- Partition keys
- Database names, etc
In this quickstart, you'll run an `order-processor` microservice that utilizes the Configuration API. The service:
1. Gets configuration items from the configuration store.
1. Subscribes for configuration updates.
<img src="/images/configuration-quickstart/configuration-quickstart-flow.png" width=1000 alt="Diagram that demonstrates the flow of the configuration API quickstart with key/value pairs used.">
Select your preferred language-specific Dapr SDK before proceeding with the Quickstart.
{{< tabs "Python" "JavaScript" ".NET" "Java" "Go" >}}
<!-- Python -->
{{% codetab %}}
### Pre-requisites
For this example, you will need:
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
- [Python 3.7+ installed](https://www.python.org/downloads/).
<!-- IGNORE_LINKS -->
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
<!-- END_IGNORE -->
### Step 1: Set up the environment
Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/configuration).
```bash
git clone https://github.com/dapr/quickstarts.git
```
Once cloned, open a new terminal and run the following command to set values for configuration items `orderId1` and `orderId2`.
```bash
docker exec dapr_redis redis-cli MSET orderId1 "101" orderId2 "102"
```
### Step 2: Run the `order-processor` service
From the root of the Quickstarts clone directory, navigate to the `order-processor` directory.
```bash
cd configuration/python/sdk/order-processor
```
Install the dependencies:
```bash
pip3 install -r requirements.txt
```
Run the `order-processor` service alongside a Dapr sidecar.
```bash
dapr run --app-id order-processor --components-path ../../../components/ --app-port 6001 -- python3 app.py
```
> **Note**: Since Python3.exe is not defined in Windows, you may need to use `python app.py` instead of `python3 app.py`.
The expected output:
```
== APP == Configuration for orderId1 : value: "101"
== APP ==
== APP == Configuration for orderId2 : value: "102"
== APP ==
== APP == App unsubscribed from config changes
```
### (Optional) Step 3: Update configuration item values
Once the app has unsubscribed, try updating the configuration item values. Change the `orderId1` and `orderId2` values using the following command:
```bash
docker exec dapr_redis redis-cli MSET orderId1 "103" orderId2 "104"
```
Run the `order-processor` service again:
```bash
dapr run --app-id order-processor --components-path ../../../components/ --app-port 6001 -- python3 app.py
```
> **Note**: Since Python3.exe is not defined in Windows, you may need to use `python app.py` instead of `python3 app.py`.
The app will return the updated configuration values:
```
== APP == Configuration for orderId1 : value: "103"
== APP ==
== APP == Configuration for orderId2 : value: "104"
== APP ==
```
### The `order-processor` service
The `order-processor` service includes code for:
- Getting the configuration items from the config store
- Subscribing to configuration updates (which you made in the CLI earlier)
- Unsubscribing from configuration updates and exiting the app after 20 seconds of inactivity.
Get configuration items:
```python
# Get config items from the config store
for config_item in CONFIGURATION_ITEMS:
config = client.get_configuration(store_name=DAPR_CONFIGURATION_STORE, keys=[config_item], config_metadata={})
print(f"Configuration for {config_item} : {config.items[config_item]}", flush=True)
```
Subscribe to configuration updates:
```python
# Subscribe for configuration changes
configuration = await client.subscribe_configuration(DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS)
```
Unsubscribe from configuration updates and exit the application:
```python
# Unsubscribe from configuration updates
unsubscribed = True
for config_item in CONFIGURATION_ITEMS:
unsub_item = client.unsubscribe_configuration(DAPR_CONFIGURATION_STORE, config_item)
#...
if unsubscribed == True:
print("App unsubscribed from config changes", flush=True)
```
{{% /codetab %}}
<!-- JavaScript -->
{{% codetab %}}
### Pre-requisites
For this example, you will need:
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
- [Python 3.7+ installed](https://www.python.org/downloads/).
<!-- IGNORE_LINKS -->
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
<!-- END_IGNORE -->
### Step 1: Set up the environment
Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/configuration).
```bash
git clone https://github.com/dapr/quickstarts.git
```
Once cloned, open a new terminal and run the following command to set values for configuration items `orderId1` and `orderId2`.
```bash
docker exec dapr_redis redis-cli MSET orderId1 "101" orderId2 "102"
```
### Step 2: Run the `order-processor` service
From the root of the Quickstarts clone directory, navigate to the `order-processor` directory.
```bash
cd configuration/javascript/sdk/order-processor
```
Install the dependencies:
```bash
npm install
```
Run the `order-processor` service alongside a Dapr sidecar.
```bash
dapr run --app-id order-processor --components-path ../../../components/ --app-protocol grpc --dapr-grpc-port 3500 -- node index.js
```
The expected output:
```
== APP == Configuration for orderId1: {"key":"orderId1","value":"101","version":"","metadata":{}}
== APP == Configuration for orderId2: {"key":"orderId2","value":"102","version":"","metadata":{}}
== APP == App unsubscribed to config changes
```
### (Optional) Step 3: Update configuration item values
Once the app has unsubscribed, try updating the configuration item values. Change the `orderId1` and `orderId2` values using the following command:
```bash
docker exec dapr_redis redis-cli MSET orderId1 "103" orderId2 "104"
```
Run the `order-processor` service again:
```bash
dapr run --app-id order-processor --components-path ../../../components/ --app-protocol grpc --dapr-grpc-port 3500 -- node index.js
```
The app will return the updated configuration values:
```
== APP == Configuration for orderId1: {"key":"orderId1","value":"103","version":"","metadata":{}}
== APP == Configuration for orderId2: {"key":"orderId2","value":"104","version":"","metadata":{}}
```
### The `order-processor` service
The `order-processor` service includes code for:
- Getting the configuration items from the config store
- Subscribing to configuration updates (which you made in the CLI earlier)
- Unsubscribing from configuration updates and exiting the app after 20 seconds of inactivity.
Get configuration items:
```javascript
// Get config items from the config store
//...
const config = await client.configuration.get(DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS);
Object.keys(config.items).forEach((key) => {
console.log("Configuration for " + key + ":", JSON.stringify(config.items[key]));
});
```
Subscribe to configuration updates:
```javascript
// Subscribe to config updates
try {
const stream = await client.configuration.subscribeWithKeys(
DAPR_CONFIGURATION_STORE,
CONFIGURATION_ITEMS,
(config) => {
console.log("Configuration update", JSON.stringify(config.items));
}
);
```
Unsubscribe from configuration updates and exit the application:
```javascript
// Unsubscribe to config updates and exit app after 20 seconds
setTimeout(() => {
stream.stop();
console.log("App unsubscribed to config changes");
process.exit(0);
},
```
{{% /codetab %}}
<!-- .NET -->
{{% codetab %}}
### Pre-requisites
For this example, you will need:
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
- [.NET SDK or .NET 6 SDK installed](https://dotnet.microsoft.com/download).
<!-- IGNORE_LINKS -->
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
<!-- END_IGNORE -->
### Step 1: Set up the environment
Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/configuration).
```bash
git clone https://github.com/dapr/quickstarts.git
```
Once cloned, open a new terminal and run the following command to set values for configuration items `orderId1` and `orderId2`.
```bash
docker exec dapr_redis redis-cli MSET orderId1 "101" orderId2 "102"
```
### Step 2: Run the `order-processor` service
From the root of the Quickstarts clone directory, navigate to the `order-processor` directory.
```bash
cd configuration/csharp/sdk/order-processor
```
Recall NuGet packages:
```bash
dotnet restore
dotnet build
```
Run the `order-processor` service alongside a Dapr sidecar.
```bash
dapr run --app-id order-processor-http --components-path ../../../components/ --app-port 7001 -- dotnet run --project .
```
The expected output:
```
== APP == Configuration for orderId1: {"Value":"101","Version":"","Metadata":{}}
== APP == Configuration for orderId2: {"Value":"102","Version":"","Metadata":{}}
== APP == App unsubscribed from config changes
```
### (Optional) Step 3: Update configuration item values
Once the app has unsubscribed, try updating the configuration item values. Change the `orderId1` and `orderId2` values using the following command:
```bash
docker exec dapr_redis redis-cli MSET orderId1 "103" orderId2 "104"
```
Run the `order-processor` service again:
```bash
dapr run --app-id order-processor-http --components-path ../../../components/ --app-port 7001 -- dotnet run --project .
```
The app will return the updated configuration values:
```
== APP == Configuration for orderId1: {"Value":"103","Version":"","Metadata":{}}
== APP == Configuration for orderId2: {"Value":"104","Version":"","Metadata":{}}
```
### The `order-processor` service
The `order-processor` service includes code for:
- Getting the configuration items from the config store
- Subscribing to configuration updates (which you made in the CLI earlier)
- Unsubscribing from configuration updates and exiting the app after 20 seconds of inactivity.
Get configuration items:
```csharp
// Get config from configuration store
GetConfigurationResponse config = await client.GetConfiguration(DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS);
foreach (var item in config.Items)
{
var cfg = System.Text.Json.JsonSerializer.Serialize(item.Value);
Console.WriteLine("Configuration for " + item.Key + ": " + cfg);
}
```
Subscribe to configuration updates:
```csharp
// Subscribe to config updates
SubscribeConfigurationResponse subscribe = await client.SubscribeConfiguration(DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS);
```
Unsubscribe from configuration updates and exit the application:
```csharp
// Unsubscribe to config updates and exit the app
try
{
client.UnsubscribeConfiguration(DAPR_CONFIGURATION_STORE, subscriptionId);
Console.WriteLine("App unsubscribed from config changes");
Environment.Exit(0);
}
```
{{% /codetab %}}
<!-- Java -->
{{% codetab %}}
### Pre-requisites
For this example, you will need:
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
- Java JDK 11 (or greater):
- [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or
- OpenJDK
- [Apache Maven](https://maven.apache.org/install.html), version 3.x.
<!-- IGNORE_LINKS -->
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
<!-- END_IGNORE -->
### Step 1: Set up the environment
Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/configuration).
```bash
git clone https://github.com/dapr/quickstarts.git
```
Once cloned, open a new terminal and run the following command to set values for configuration items `orderId1` and `orderId2`.
```bash
docker exec dapr_redis redis-cli MSET orderId1 "101" orderId2 "102"
```
### Step 2: Run the `order-processor` service
From the root of the Quickstarts clone directory, navigate to the `order-processor` directory.
```bash
cd configuration/java/sdk/order-processor
```
Install the dependencies:
```bash
mvn clean install
```
Run the `order-processor` service alongside a Dapr sidecar.
```bash
dapr run --app-id order-processor --components-path ../../../components -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar
```
The expected output:
```
== APP == Configuration for orderId1: {'value':'101'}
== APP == Configuration for orderId2: {'value':'102'}
== APP == App unsubscribed to config changes
```
### (Optional) Step 3: Update configuration item values
Once the app has unsubscribed, try updating the configuration item values. Change the `orderId1` and `orderId2` values using the following command:
```bash
docker exec dapr_redis redis-cli MSET orderId1 "103" orderId2 "104"
```
Run the `order-processor` service again:
```bash
dapr run --app-id order-processor --components-path ../../../components -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar
```
The app will return the updated configuration values:
```
== APP == Configuration for orderId1: {'value':'103'}
== APP == Configuration for orderId2: {'value':'104'}
```
### The `order-processor` service
The `order-processor` service includes code for:
- Getting the configuration items from the config store
- Subscribing to configuration updates (which you made in the CLI earlier)
- Unsubscribing from configuration updates and exiting the app after 20 seconds of inactivity.
Get configuration items:
```java
// Get config items from the config store
try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) {
for (String configurationItem : CONFIGURATION_ITEMS) {
ConfigurationItem item = client.getConfiguration(DAPR_CONFIGURATON_STORE, configurationItem).block();
System.out.println("Configuration for " + configurationItem + ": {'value':'" + item.getValue() + "'}");
}
```
Subscribe to configuration updates:
```java
// Subscribe for config changes
Flux<SubscribeConfigurationResponse> subscription = client.subscribeConfiguration(DAPR_CONFIGURATON_STORE,
CONFIGURATION_ITEMS.toArray(String[]::new));
```
Unsubscribe from configuration updates and exit the application:
```java
// Unsubscribe from config changes
UnsubscribeConfigurationResponse unsubscribe = client
.unsubscribeConfiguration(subscriptionId, DAPR_CONFIGURATON_STORE).block();
if (unsubscribe.getIsUnsubscribed()) {
System.out.println("App unsubscribed to config changes");
}
```
{{% /codetab %}}
<!-- Go -->
{{% codetab %}}
### Pre-requisites
For this example, you will need:
- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started).
- [Latest version of Go](https://go.dev/dl/).
<!-- IGNORE_LINKS -->
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
<!-- END_IGNORE -->
### Step 1: Set up the environment
Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/configuration).
```bash
git clone https://github.com/dapr/quickstarts.git
```
Once cloned, open a new terminal and run the following command to set values for configuration items `orderId1` and `orderId2`.
```bash
docker exec dapr_redis redis-cli MSET orderId1 "101" orderId2 "102"
```
### Step 2: Run the `order-processor` service
From the root of the Quickstarts clone directory, navigate to the `order-processor` directory.
```bash
cd configuration/go/sdk/order-processor
```
Run the `order-processor` service alongside a Dapr sidecar.
```bash
dapr run --app-id order-processor --app-port 6001 --components-path ../../../components -- go run .
```
The expected output:
```
== APP == Configuration for orderId1: {"Value":"101","Version":"","Metadata":null}
== APP == Configuration for orderId2: {"Value":"102","Version":"","Metadata":null}
== APP == dapr configuration subscribe finished.
== APP == App unsubscribed to config changes
```
### (Optional) Step 3: Update configuration item values
Once the app has unsubscribed, try updating the configuration item values. Change the `orderId1` and `orderId2` values using the following command:
```bash
docker exec dapr_redis redis-cli MSET orderId1 "103" orderId2 "104"
```
Run the `order-processor` service again:
```bash
dapr run --app-id order-processor --app-port 6001 --components-path ../../../components -- go run .
```
The app will return the updated configuration values:
```
== APP == Configuration for orderId1: {"Value":"103","Version":"","Metadata":null}
== APP == Configuration for orderId2: {"Value":"104","Version":"","Metadata":null}
```
### The `order-processor` service
The `order-processor` service includes code for:
- Getting the configuration items from the config store
- Subscribing to configuration updates (which you made in the CLI earlier)
- Unsubscribing from configuration updates and exiting the app after 20 seconds of inactivity.
Get configuration items:
```go
// Get config items from config store
for _, item := range CONFIGURATION_ITEMS {
config, err := client.GetConfigurationItem(ctx, DAPR_CONFIGURATION_STORE, item)
//...
c, _ := json.Marshal(config)
fmt.Println("Configuration for " + item + ": " + string(c))
}
```
Subscribe to configuration updates:
```go
// Subscribe for config changes
err = client.SubscribeConfigurationItems(ctx, DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS, func(id string, config map[string]*dapr.ConfigurationItem) {
// First invocation when app subscribes to config changes only returns subscription id
if len(config) == 0 {
fmt.Println("App subscribed to config changes with subscription id: " + id)
subscriptionId = id
return
}
})
```
Unsubscribe from configuration updates and exit the application:
```go
// Unsubscribe to config updates and exit app after 20 seconds
select {
case <-ctx.Done():
err = client.UnsubscribeConfigurationItems(context.Background(), DAPR_CONFIGURATION_STORE, subscriptionId)
//...
{
fmt.Println("App unsubscribed to config changes")
}
```
{{% /codetab %}}
{{< /tabs >}}
## Tell us what you think!
We're continuously working to improve our Quickstart examples and value your feedback. Did you find this quickstart helpful? Do you have suggestions for improvement?
Join the discussion in our [discord channel](https://discord.com/channels/778680217417809931/953427615916638238).
## Next steps
- Use Dapr Configuration with HTTP instead of an SDK.
- [Python](https://github.com/dapr/quickstarts/tree/master/configuration/python/http)
- [JavaScript](https://github.com/dapr/quickstarts/tree/master/configuration/javascript/http)
- [.NET](https://github.com/dapr/quickstarts/tree/master/configuration/csharp/http)
- [Java](https://github.com/dapr/quickstarts/tree/master/configuration/java/http)
- [Go](https://github.com/dapr/quickstarts/tree/master/configuration/go/http)
- Learn more about [Configuration building block]({{< ref configuration-api-overview >}})
{{< button text="Explore Dapr tutorials >>" page="getting-started/tutorials/_index.md" >}}

View File

@ -106,7 +106,7 @@ In the YAML file:
**`secrets.json` file**
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/javascript/sdk/order-processor/secrets.json):
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/python/sdk/order-processor/secrets.json):
```json
{
@ -328,7 +328,7 @@ In the YAML file:
**`secrets.json` file**
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/csharp/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/javascript/sdk/order-processor/secrets.json):
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/csharp/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/csharp/sdk/order-processor/secrets.json):
```json
{
@ -436,7 +436,7 @@ In the YAML file:
**`secrets.json` file**
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/javascript/sdk/order-processor/secrets.json):
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/java/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/java/sdk/order-processor/secrets.json):
```json
{
@ -543,7 +543,7 @@ In the YAML file:
**`secrets.json` file**
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/javascript/sdk/order-processor/secrets.json):
`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/go/sdk/order-processor](https://github.com/dapr/quickstarts/tree/master/secrets_management/go/sdk/order-processor/secrets.json):
```json
{

View File

@ -64,9 +64,11 @@ There are some scenarios where it's necessary to install Dapr from a private Hel
- having a custom Dapr deployment
- pulling Helm charts from trusted registries that are managed and maintained by your organization
```
export DAPR_HELM_REPO_URL="https://helm.custom-domain.com/dapr/dapr"
export DAPR_HELM_REPO_USERNAME="username_xxx"
export DAPR_HELM_REPO_PASSWORD="passwd_xxx"
```
Setting the above parameters will allow `dapr init -k` to install Dapr images from the configured Helm repository.

View File

@ -50,45 +50,54 @@ spec:
imagePullPolicy: Always
```
If your pod spec template is annotated correctly and you still don't see the sidecar injected, make sure Dapr was deployed to the cluster before your deployment or pod were deployed.
There are some known cases where this might not properly work:
If this is the case, restarting the pods will fix the issue.
- If your pod spec template is annotated correctly, and you still don't see the sidecar injected, make sure Dapr was deployed to the cluster before your deployment or pod were deployed.
If you are deploying Dapr on a private GKE cluster, sidecar injection does not work without extra steps. See [Setup a Google Kubernetes Engine cluster]({{< ref setup-gke.md >}}).
If this is the case, restarting the pods will fix the issue.
In order to further diagnose any issue, check the logs of the Dapr sidecar injector:
- If you are deploying Dapr on a private GKE cluster, sidecar injection does not work without extra steps. See [Setup a Google Kubernetes Engine cluster]({{< ref setup-gke.md >}}).
```bash
kubectl logs -l app=dapr-sidecar-injector -n dapr-system
```
In order to further diagnose any issue, check the logs of the Dapr sidecar injector:
*Note: If you installed Dapr to a different namespace, replace dapr-system above with the desired namespace*
```bash
kubectl logs -l app=dapr-sidecar-injector -n dapr-system
```
If you are deploying Dapr on Amazon EKS and using an overlay network such as Calico, you will need to set `hostNetwork` parameter to true, this is a limitation of EKS with such CNIs.
*Note: If you installed Dapr to a different namespace, replace dapr-system above with the desired namespace*
You can set this parameter using Helm `values.yaml` file:
- If you are deploying Dapr on Amazon EKS and using an overlay network such as Calico, you will need to set `hostNetwork` parameter to true, this is a limitation of EKS with such CNIs.
```
helm upgrade --install dapr dapr/dapr \
You can set this parameter using Helm `values.yaml` file:
```
helm upgrade --install dapr dapr/dapr \
--namespace dapr-system \
--create-namespace \
--values values.yaml
```
```
`values.yaml`
```yaml
dapr_sidecar_injector:
hostNetwork: true
```
`values.yaml`
```yaml
dapr_sidecar_injector:
hostNetwork: true
```
or using command line:
or using command line:
```
helm upgrade --install dapr dapr/dapr \
```
helm upgrade --install dapr dapr/dapr \
--namespace dapr-system \
--create-namespace \
--set dapr_sidecar_injector.hostNetwork=true
```
```
- Make sure the kube api server can reach the following webhooks services:
- [Sidecar Mutating Webhook Injector Service](https://github.com/dapr/dapr/blob/44235fe8e8799589bb393a3124d2564db2dd6885/charts/dapr/charts/dapr_sidecar_injector/templates/dapr_sidecar_injector_deployment.yaml#L157) at port __4000__ that is served from the sidecar injector.
- [CRD Conversion Webhook Service](https://github.com/dapr/dapr/blob/44235fe8e8799589bb393a3124d2564db2dd6885/charts/dapr/charts/dapr_operator/templates/dapr_operator_service.yaml#L28) at port __19443__ that is served from the operator.
Check with your cluster administrators to setup allow ingress
rules to the above ports, __4000__ and __19443__, in the cluster from the kube api servers.
## My pod is in CrashLoopBackoff or another failed state due to the daprd sidecar

View File

@ -42,6 +42,7 @@ Available Commands:
stop Stop Dapr instances and their associated apps. Supported platforms: Self-hosted
uninstall Uninstall Dapr runtime. Supported platforms: Kubernetes and self-hosted
upgrade Upgrades a Dapr control plane installation in a cluster. Supported platforms: Kubernetes
version Print the Dapr runtime and CLI version
Flags:
-h, --help help for dapr
@ -73,8 +74,8 @@ You can learn more about each Dapr command from the links below.
- [`dapr stop`]({{< ref dapr-stop.md >}})
- [`dapr uninstall`]({{< ref dapr-uninstall.md >}})
- [`dapr upgrade`]({{< ref dapr-upgrade.md >}})
- [`dapr-version`]({{< ref dapr-version.md >}})
- [`dapr version`]({{< ref dapr-version.md >}})
### Environment Variables
Some Dapr flags can be set via environment variables (e.g. `DAPR_NETWORK` for the `--network` flag of the `dapr init` command). Note that specifying the flag on the command line overrides any set environment variable.
Some Dapr flags can be set via environment variables (e.g. `DAPR_NETWORK` for the `--network` flag of the `dapr init` command). Note that specifying the flag on the command line overrides any set environment variable.

View File

@ -85,8 +85,8 @@ The above example uses secrets as plain strings. It is recommended to use a secr
| enableTLS | N | If the Redis instance supports TLS with public certificates, can be configured to be enabled or disabled. Defaults to `"false"` | `"true"`, `"false"`
| maxRetries | N | Maximum number of retries before giving up. Defaults to `3` | `5`, `10`
| maxRetryBackoff | N | Maximum backoff between each retry. Defaults to `2` seconds; `"-1"` disables backoff. | `3000000000`
| failover | N | Property to enabled failover configuration. Needs sentinalMasterName to be set. The redisHost should be the sentinel host address. See [Redis Sentinel Documentation](https://redis.io/docs/manual/sentinel/). Defaults to `"false"` | `"true"`, `"false"`
| sentinelMasterName | N | The sentinel master name. See [Redis Sentinel Documentation](https://redis.io/docs/manual/sentinel/) | `""`, `"127.0.0.1:6379"`
| failover | N | Property to enabled failover configuration. Needs sentinelMasterName to be set. The redisHost should be the sentinel host address. See [Redis Sentinel Documentation](https://redis.io/docs/manual/sentinel/). Defaults to `"false"` | `"true"`, `"false"`
| sentinelMasterName | N | The sentinel master name. See [Redis Sentinel Documentation](https://redis.io/docs/manual/sentinel/) | `"mymaster"`
| redeliverInterval | N | The interval between checking for pending messages to redelivery. Defaults to `"60s"`. `"0"` disables redelivery. | `"30s"`
| processingTimeout | N | The amount time a message must be pending before attempting to redeliver it. Defaults to `"15s"`. `"0"` disables redelivery. | `"30s"`
| redisType | N | The type of redis. There are two valid values, one is `"node"` for single node mode, the other is `"cluster"` for redis cluster mode. Defaults to `"node"`. | `"cluster"`

View File

@ -14,10 +14,10 @@ extension.
The Wasm [HTTP middleware]({{< ref middleware.md >}}) allows you to rewrite a
request URI with custom logic compiled to a Wasm binary. In other words, you
can extend Dapr using external files that are not pre-compiled into the `daprd`
binary. Dapr embeds [wazero][https://wazero.io] to accomplish this without CGO.
binary. Dapr embeds [wazero](https://wazero.io) to accomplish this without CGO.
Wasm modules are loaded from a filesystem path. On Kubernetes, see [mounting
volumes to the Dapr sidecar]({{> kubernetes-volume-mounts.md >}}) to configure
volumes to the Dapr sidecar]({{< ref kubernetes-volume-mounts.md >}}) to configure
a filesystem mount that can contain Wasm modules.
## Component format

View File

@ -62,7 +62,7 @@ spec:
value: false
- name: rateLimit
value: 1024
- name: hearbeat
- name: heartbeat
value: 15s
- name: ackPolicy
value: explicit
@ -98,7 +98,7 @@ spec:
| replicas | N | [Replicas] | `3` |
| memoryStorage | N | [Memory Storage] | `false` |
| rateLimit | N | [Rate Limit] | `1024` |
| hearbeat | N | [Hearbeat] | `10s` |
| heartbeat | N | [Heartbeat] | `10s` |
| ackPolicy | N | [Ack Policy] | `explicit` |
| deliverPolicy | N | One of: all, last, new, sequence, time | `all` |
| domain | N | [JetStream Leafondes] | `HUB` |
@ -166,7 +166,7 @@ nats -s localhost:4222 stream add myStream --subjects mySubject
[Replicas]: https://docs.nats.io/jetstream/concepts/consumers#replicas
[Memory Storage]: https://docs.nats.io/jetstream/concepts/consumers#memorystorage
[Rate Limit]: https://docs.nats.io/jetstream/concepts/consumers#ratelimit
[Hearbeat]: https://docs.nats.io/jetstream/concepts/consumers#hearbeat
[Heartbeat]: https://docs.nats.io/jetstream/concepts/consumers#heartbeat
[Ack Policy]: https://docs.nats.io/nats-concepts/jetstream/consumers#ackpolicy
[JetStream Leafonodes]: https://docs.nats.io/running-a-nats-service/configuration/leafnodes/jetstream_leafnodes
[Decentralized JWT Authentication/Authorization]: https://docs.nats.io/running-a-nats-service/configuration/securing_nats/auth_intro/jwt

View File

@ -21,11 +21,22 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-bindings/{{ .link }}/" }}>{{ .component
}}</a>
<td><a href="/reference/components-reference/supported-bindings/{{ .link }}/">{{ .component }}</a>
</td>
<td align="center">
{{ if .features.input }}
<span role="img" aria-label="Input binding supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="Input binding not supported" aria-label="Input binding not supported">
{{ end }}
</td>
<td align="center">
{{ if .features.output }}
<span role="img" aria-label="Output binding supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="Output binding not supported" aria-label="Output binding not supported">
{{ end }}
</td>
<td align="center">{{ if .features.input }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td align="center">{{ if .features.output }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>
<td>{{ .since }}</td>

View File

@ -13,8 +13,7 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-configuration-stores/{{ .link }}/" }}>{{ .component
}}</a>
<td><a href="/reference/components-reference/supported-configuration-stores/{{ .link }}/">{{ .component }}</a>
</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>

View File

@ -1,7 +1,6 @@
<p>Table captions:</p>
<blockquote>
<p><code>Status</code>: <a href="/operations/components/certification-lifecycle/">Component
certification</a> status</p>
<p><code>Status</code>: <a href="/operations/components/certification-lifecycle/">component certification</a> status</p>
</blockquote>
<ul>
<li><a href="/operations/components/certification-lifecycle/#alpha">Alpha</a></li>
@ -9,8 +8,8 @@
<li><a href="/operations/components/certification-lifecycle/#stable">Stable</a></li>
</ul>
<blockquote>
<p><code>Since</code>: defines from which Dapr Runtime version, the component is in the current status</p>
<p><code>Since</code>: the version of the Dapr Runtime in which the component first moved to the current status</p>
</blockquote>
<blockquote>
<p><code>Component version</code>: defines the version of the component</p>
<p><code>Component version</code>: the version of the component</p>
</blockquote>

View File

@ -13,8 +13,7 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-locks/{{ .link }}/" }}>{{ .component
}}</a>
<td><a href="/reference/components-reference/supported-locks/{{ .link }}/">{{ .component }}</a>
</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>

View File

@ -13,8 +13,7 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="{{ .link }}/" }}>{{ .component
}}</a>
<td><a href="{{ .link }}/">{{ .component }}</a>
</td>
<td>{{ .description | markdownify}}</td>
<td>{{ .state }}</td>

View File

@ -15,8 +15,7 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-name-resolution/{{ .link }}/" }}>{{ .component
}}</a>
<td><a href="/reference/components-reference/supported-name-resolution/{{ .link }}/">{{ .component }}</a>
</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>

View File

@ -16,8 +16,7 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-pubsub/{{ .link }}/" }}>{{ .component
}}</a>
<td><a href="/reference/components-reference/supported-pubsub/{{ .link }}/">{{ .component }}</a>
</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>

View File

@ -27,10 +27,16 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-secret-stores/{{ .link }}/" }}>{{ .component
}}</a>
<td>
<a href="/reference/components-reference/supported-secret-stores/{{ .link }}/">{{ .component }}</a>
</td>
<td align="center">
{{ if .features.multipleKeyValuesPerSecret }}
<span role="img" aria-label="Multiple Key-Values Per Secret: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="Multiple Key-Values Per Secret: Not supported" aria-label="Multiple Key-Values Per Secret: Not supported" />
{{ end }}
</td>
<td align="center">{{ if .features.multipleKeyValuesPerSecret }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>
<td>{{ .since }}</td>

View File

@ -24,16 +24,51 @@
</tr>
{{ range sort $components "component" }}
<tr>
<td><a href="/reference/components-reference/supported-state-stores/{{ .link }}/" }}>{{ .component
}}</a>
<td>
<a href="/reference/components-reference/supported-state-stores/{{ .link }}/">{{ .component }}</a>
</td>
<td align="center">
{{ if .features.crud }}
<span role="img" aria-label="CRUD: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="CRUD: Not supported" aria-label="CRUD: Not supported" />
{{ end }}
</td>
<td align="center">
{{ if .features.transactions }}
<span role="img" aria-label="Transactions: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="Transactions: Not supported" aria-label="Transactions: Not supported" />
{{ end }}
</td>
<td align="center">
{{ if .features.etag }}
<span role="img" aria-label="ETag: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="ETag: Not supported" aria-label="ETag: Not supported" />
{{ end }}
</td>
<td align="center">
{{ if .features.ttl }}
<span role="img" aria-label="TTL: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="TTL: Not supported" aria-label="TTL: Not supported" />
{{ end }}
</td>
<td align="center">
{{ if (and .features.transactions .features.etag) }}
<span role="img" aria-label="Actors: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="Actors: Not supported" aria-label="Actors: Not supported" />
{{ end }}
</td>
<td align="center">
{{ if .features.query }}
<span role="img" aria-label="Query: Supported"></span>
{{else}}
<img src="/images/emptybox.png" alt="Query: Not supported" aria-label="Query: Not supported" />
{{ end }}
</td>
<td align="center">{{ if .features.crud }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td align="center">{{ if .features.transactions }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td align="center">{{ if .features.etag }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td align="center">{{ if .features.ttl }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td align="center">{{ if (and .features.transactions .features.etag) }}✅{{else}}<img
src="/images/emptybox.png">{{ end }}</td>
<td align="center">{{ if .features.query }}✅{{else}}<img src="/images/emptybox.png">{{ end }}</td>
<td>{{ .state }}</td>
<td>{{ .version }}</td>
<td>{{ .since }}</td>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB