Skip to content

Commit 6d1d869

Browse files
authored
Add SchedulerHostAddress to DaprSidecarOptions (#6478)
I enhanced DaprSidecarOptions by adding the SchedulerHostAddress property. This will allow the developer to specify the host address of the Dapr scheduler service if not running on localhost (for example, if developing using Docker Compose, the scheduler service will be running on a different host). I enhanced the DaprDistributedApplicationLifecycleHook to pass the --scheduler-host-address parameter to the Dapr sidecar if the DaprSidecarOptions.SchedulerHostAddress property is specified. Resolves #6477
1 parent 3e9773a commit 6d1d869

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/Aspire.Hosting.Dapr/DaprDistributedApplicationLifecycleHook.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell
142142
ModelNamedArg("--resources-path", aggregateResourcesPaths),
143143
ModelNamedArg("--run-file", NormalizePath(sidecarOptions?.RunFile)),
144144
ModelNamedArg("--runtime-path", NormalizePath(sidecarOptions?.RuntimePath)),
145+
ModelNamedArg("--scheduler-host-address", sidecarOptions?.SchedulerHostAddress),
145146
ModelNamedArg("--unix-domain-socket", sidecarOptions?.UnixDomainSocket),
146147
PostOptionsArgs(Args(sidecarOptions?.Command)));
147148

@@ -262,6 +263,7 @@ public async Task BeforeStartAsync(DistributedApplicationModel appModel, Cancell
262263
context.Writer.TryWriteStringArray("resourcesPath", sidecarOptions?.ResourcesPaths.Select(path => context.GetManifestRelativePath(path)));
263264
context.Writer.TryWriteString("runFile", context.GetManifestRelativePath(sidecarOptions?.RunFile));
264265
context.Writer.TryWriteString("runtimePath", context.GetManifestRelativePath(sidecarOptions?.RuntimePath));
266+
context.Writer.TryWriteString("schedulerHostAddress", sidecarOptions?.SchedulerHostAddress);
265267
context.Writer.TryWriteString("unixDomainSocket", sidecarOptions?.UnixDomainSocket);
266268

267269
context.Writer.WriteEndObject();

src/Aspire.Hosting.Dapr/DaprSidecarOptions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ public sealed record DaprSidecarOptions
157157
/// </summary>
158158
public string? RuntimePath { get; init; }
159159

160+
/// <summary>
161+
/// Gets or sets the address of the scheduler service.
162+
/// </summary>
163+
/// <remarks>
164+
/// The format is either "hostname" for the default port or "hostname:port" for a custom port.
165+
/// The default is "localhost".
166+
/// </remarks>
167+
public string? SchedulerHostAddress { get; init; }
168+
160169
/// <summary>
161170
/// Gets or sets the path to a Unix Domain Socket (UDS) directory.
162171
/// </summary>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#nullable enable
2-
2+
Aspire.Hosting.Dapr.DaprSidecarOptions.SchedulerHostAddress.get -> string?
3+
Aspire.Hosting.Dapr.DaprSidecarOptions.SchedulerHostAddress.init -> void

0 commit comments

Comments
 (0)