You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add optional parameter to configuration providers for non-blocking startup
Configuration and secret store providers now accept an `optional` parameter
that allows applications to start without blocking on sidecar availability.
When optional, configuration loads in the background with resilient retry
logic that handles transient Dapr errors gracefully.
- Add `optional` parameter to AddDaprConfigurationStore and AddDaprSecretStore
- Harden LoadInBackgroundAsync to catch OperationCanceledException and
DaprException separately, avoiding silent swallowing of programming errors
- Dispose CancellationTokenSource in both providers to prevent resource leaks
- Fix StringComparer inconsistency (InvariantCultureIgnoreCase → OrdinalIgnoreCase)
- Mark fields readonly in DaprConfigurationStoreProvider for consistency
- Restore UTF-8 BOM per .editorconfig and add missing trailing newlines
- Add deterministic tests using reload tokens instead of fragile Task.Delay
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: George Tsiokos <george@tsiokos.com>
Copy file name to clipboardExpand all lines: src/Dapr.Extensions.Configuration/DaprConfigurationStoreExtension.cs
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -34,14 +34,16 @@ public static class DaprConfigurationStoreExtension
34
34
/// <param name="client">The <see cref="DaprClient"/> used for the request.</param>
35
35
/// <param name="sidecarWaitTimeout">The <see cref="TimeSpan"/> used to configure the timeout waiting for Dapr.</param>
36
36
/// <param name="metadata">Optional metadata sent to the configuration store.</param>
37
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Configuration is loaded in the background once the sidecar becomes available.</param>
@@ -54,7 +56,8 @@ public static IConfigurationBuilder AddDaprConfigurationStore(
54
56
Client=client,
55
57
SidecarWaitTimeout=sidecarWaitTimeout,
56
58
IsStreaming=false,
57
-
Metadata=metadata
59
+
Metadata=metadata,
60
+
IsOptional=optional
58
61
});
59
62
60
63
returnconfigurationBuilder;
@@ -71,14 +74,16 @@ public static IConfigurationBuilder AddDaprConfigurationStore(
71
74
/// <param name="client">The <see cref="DaprClient"/> used for the request.</param>
72
75
/// <param name="sidecarWaitTimeout">The <see cref="TimeSpan"/> used to configure the timeout waiting for Dapr.</param>
73
76
/// <param name="metadata">Optional metadata sent to the configuration store.</param>
77
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Configuration is loaded in the background once the sidecar becomes available.</param>
Copy file name to clipboardExpand all lines: src/Dapr.Extensions.Configuration/DaprSecretStoreConfigurationExtensions.cs
+35-17Lines changed: 35 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -32,12 +32,14 @@ public static class DaprSecretStoreConfigurationExtensions
32
32
/// <param name="store">Dapr secret store name.</param>
33
33
/// <param name="secretDescriptors">The secrets to retrieve.</param>
34
34
/// <param name="client">The Dapr client</param>
35
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Secrets are loaded in the background once the sidecar becomes available.</param>
@@ -47,7 +49,8 @@ public static IConfigurationBuilder AddDaprSecretStore(
47
49
{
48
50
Store=store,
49
51
SecretDescriptors=secretDescriptors,
50
-
Client=client
52
+
Client=client,
53
+
IsOptional=optional
51
54
});
52
55
53
56
returnconfigurationBuilder;
@@ -61,13 +64,15 @@ public static IConfigurationBuilder AddDaprSecretStore(
61
64
/// <param name="secretDescriptors">The secrets to retrieve.</param>
62
65
/// <param name="client">The Dapr client.</param>
63
66
/// <param name="sidecarWaitTimeout">The <see cref="TimeSpan"/> used to configure the timeout waiting for Dapr.</param>
67
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Secrets are loaded in the background once the sidecar becomes available.</param>
@@ -78,7 +83,8 @@ public static IConfigurationBuilder AddDaprSecretStore(
78
83
Store=store,
79
84
SecretDescriptors=secretDescriptors,
80
85
Client=client,
81
-
SidecarWaitTimeout=sidecarWaitTimeout
86
+
SidecarWaitTimeout=sidecarWaitTimeout,
87
+
IsOptional=optional
82
88
});
83
89
84
90
returnconfigurationBuilder;
@@ -89,14 +95,16 @@ public static IConfigurationBuilder AddDaprSecretStore(
89
95
/// </summary>
90
96
/// <param name="configurationBuilder">The <see cref="IConfigurationBuilder"/> to add to.</param>
91
97
/// <param name="store">Dapr secret store name.</param>
92
-
/// <param name="metadata">A collection of metadata key-value pairs that will be provided to the secret store. The valid metadata keys and values are determined by the type of secret store used.</param>
93
98
/// <param name="client">The Dapr client</param>
99
+
/// <param name="metadata">A collection of metadata key-value pairs that will be provided to the secret store. The valid metadata keys and values are determined by the type of secret store used.</param>
100
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Secrets are loaded in the background once the sidecar becomes available.</param>
@@ -105,7 +113,8 @@ public static IConfigurationBuilder AddDaprSecretStore(
105
113
{
106
114
Store=store,
107
115
Metadata=metadata,
108
-
Client=client
116
+
Client=client,
117
+
IsOptional=optional
109
118
});
110
119
111
120
returnconfigurationBuilder;
@@ -116,16 +125,18 @@ public static IConfigurationBuilder AddDaprSecretStore(
116
125
/// </summary>
117
126
/// <param name="configurationBuilder">The <see cref="IConfigurationBuilder"/> to add to.</param>
118
127
/// <param name="store">Dapr secret store name.</param>
119
-
/// <param name="metadata">A collection of metadata key-value pairs that will be provided to the secret store. The valid metadata keys and values are determined by the type of secret store used.</param>
120
128
/// <param name="client">The Dapr client</param>
121
129
/// <param name="sidecarWaitTimeout">The <see cref="TimeSpan"/> used to configure the timeout waiting for Dapr.</param>
130
+
/// <param name="metadata">A collection of metadata key-value pairs that will be provided to the secret store. The valid metadata keys and values are determined by the type of secret store used.</param>
131
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Secrets are loaded in the background once the sidecar becomes available.</param>
@@ -135,7 +146,8 @@ public static IConfigurationBuilder AddDaprSecretStore(
135
146
Store=store,
136
147
Metadata=metadata,
137
148
Client=client,
138
-
SidecarWaitTimeout=sidecarWaitTimeout
149
+
SidecarWaitTimeout=sidecarWaitTimeout,
150
+
IsOptional=optional
139
151
});
140
152
141
153
returnconfigurationBuilder;
@@ -146,22 +158,25 @@ public static IConfigurationBuilder AddDaprSecretStore(
146
158
/// </summary>
147
159
/// <param name="configurationBuilder">The <see cref="IConfigurationBuilder"/> to add to.</param>
148
160
/// <param name="store">Dapr secret store name.</param>
149
-
/// <param name="keyDelimiters">A collection of delimiters that will be replaced by ':' in the key of every secret.</param>
150
161
/// <param name="client">The Dapr client</param>
162
+
/// <param name="keyDelimiters">A collection of delimiters that will be replaced by ':' in the key of every secret.</param>
163
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Secrets are loaded in the background once the sidecar becomes available.</param>
@@ -179,16 +194,18 @@ public static IConfigurationBuilder AddDaprSecretStore(
179
194
/// </summary>
180
195
/// <param name="configurationBuilder">The <see cref="IConfigurationBuilder"/> to add to.</param>
181
196
/// <param name="store">Dapr secret store name.</param>
182
-
/// <param name="keyDelimiters">A collection of delimiters that will be replaced by ':' in the key of every secret.</param>
183
197
/// <param name="client">The Dapr client</param>
198
+
/// <param name="keyDelimiters">A collection of delimiters that will be replaced by ':' in the key of every secret.</param>
184
199
/// <param name="sidecarWaitTimeout">The <see cref="TimeSpan"/> used to configure the timeout waiting for Dapr.</param>
200
+
/// <param name="optional">When true, does not block startup waiting for the sidecar. Secrets are loaded in the background once the sidecar becomes available.</param>
0 commit comments