Skip to content

Commit

Permalink
Added dynamic configuration for Temporal server
Browse files Browse the repository at this point in the history
The `Program.cs` file has been updated to include a new dynamic configuration value for the Temporal server container. A new property `DynamicConfigValues` has been added to the `TemporalServerResourceArguments.cs` file, and the `GetArgs()` method has been updated to include these dynamic configuration values. The `TemporalServerResourceBuilder.cs` file has been updated with slightly modified comments for better readability and a new method `WithDynamicConfigValue` for specifying dynamic configuration values.
  • Loading branch information
ElanHasson committed May 13, 2024
1 parent 863cf22 commit c9eed73
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sample/AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Aspire.Hosting;

using InfinityFlow.Aspire.Temporal;

var builder = DistributedApplication.CreateBuilder(args);

var temporal = await builder.AddTemporalServerContainer("temporal", x => x
.WithLogFormat(LogFormat.Json)
.WithLogLevel(LogLevel.Info)
.WithNamespace("test1", "test2"));
.WithNamespace("test1", "test2")
.WithDynamicConfigValue("frontend.enableUpdateWorkflowExecution", true)
);

builder.AddProject<Projects.Api>("api")
.WithReference(temporal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public class TemporalServerResourceArguments
/// </summary>
public List<string> Namespaces { get; set; } = [];

/// <summary>
/// Gets the list of dynamic config values.
/// </summary>
public Dictionary<string, object> DynamicConfigValues { get; set; } = [];

/// <summary>
/// Converts the current instance's properties to an array of command-line arguments for starting the Temporal server.
/// </summary>
Expand Down Expand Up @@ -128,6 +133,22 @@ public string[] GetArgs()
result.Add(name);
}

foreach (var (k, v) in DynamicConfigValues)
{
result.Add("--dynamic-config-value");

result.Add($"{k}={v switch
{
string s => $""" "{v}" """,
bool b => b.ToString().ToLowerInvariant(),
int i => i.ToString(),
float f => f.ToString("F"),
double d => d.ToString("F"),
long l => l.ToString(),
_ => null,
}}");
}

return [.. result];
}

Expand Down
16 changes: 14 additions & 2 deletions src/InfinityFlow.Aspire.Temporal/TemporalServerResourceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public TemporalServerResourceBuilder WithIp(string ip)
}

/// <summary>
/// IPv4 address to bind the Web UI to (default: same as --ip)
/// IPv4 address to bind the Web UI to (default: same as --ip)
/// </summary>
/// <param name="uiIp"></param>
/// <returns></returns>
Expand All @@ -105,7 +105,7 @@ public TemporalServerResourceBuilder WithUiIp(string uiIp)
}

/// <summary>
/// UI custom assets path
/// UI custom assets path
/// </summary>
/// <param name="assetsPath"></param>
/// <returns></returns>
Expand Down Expand Up @@ -171,4 +171,16 @@ public TemporalServerResourceBuilder WithNamespace(params string[] namespaces)
}

public TemporalServerResourceArguments Build() => Args;

/// <summary>
/// Specify dynamic config values that should be configured.
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public TemporalServerResourceBuilder WithDynamicConfigValue(string key, object value)
{
Args.DynamicConfigValues.Add(key, value);
return this;
}
}

0 comments on commit c9eed73

Please sign in to comment.