From 778c7db787e54f9a0cebba3cd25f8ec138ebcb7d Mon Sep 17 00:00:00 2001 From: Spencer Judge Date: Tue, 4 Feb 2025 17:58:02 -0800 Subject: [PATCH] Add dev server UI port --- src/Temporalio/Bridge/OptionsExtensions.cs | 1 + src/Temporalio/Bridge/include/temporal-sdk-bridge.h | 1 + src/Temporalio/Bridge/src/testing.rs | 6 ++++++ .../Testing/WorkflowEnvironmentStartLocalOptions.cs | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/src/Temporalio/Bridge/OptionsExtensions.cs b/src/Temporalio/Bridge/OptionsExtensions.cs index 68aaa250..217f7d29 100644 --- a/src/Temporalio/Bridge/OptionsExtensions.cs +++ b/src/Temporalio/Bridge/OptionsExtensions.cs @@ -393,6 +393,7 @@ public static unsafe Interop.DevServerOptions ToInteropOptions( ip = scope.ByteArray(ip), database_filename = scope.ByteArray(options.DevServerOptions.DatabaseFilename), ui = (byte)(options.UI ? 1 : 0), + ui_port = (ushort)options.UIPort, log_format = scope.ByteArray(options.DevServerOptions.LogFormat), log_level = scope.ByteArray(options.DevServerOptions.LogLevel), }; diff --git a/src/Temporalio/Bridge/include/temporal-sdk-bridge.h b/src/Temporalio/Bridge/include/temporal-sdk-bridge.h index d081d9a8..791c9844 100644 --- a/src/Temporalio/Bridge/include/temporal-sdk-bridge.h +++ b/src/Temporalio/Bridge/include/temporal-sdk-bridge.h @@ -352,6 +352,7 @@ typedef struct DevServerOptions { */ struct ByteArrayRef database_filename; bool ui; + uint16_t ui_port; struct ByteArrayRef log_format; struct ByteArrayRef log_level; } DevServerOptions; diff --git a/src/Temporalio/Bridge/src/testing.rs b/src/Temporalio/Bridge/src/testing.rs index d4482684..99aa3636 100644 --- a/src/Temporalio/Bridge/src/testing.rs +++ b/src/Temporalio/Bridge/src/testing.rs @@ -19,6 +19,7 @@ pub struct DevServerOptions { /// Empty means default behavior database_filename: ByteArrayRef, ui: bool, + ui_port: u16, log_format: ByteArrayRef, log_level: ByteArrayRef, } @@ -208,6 +209,11 @@ impl TryFrom<&DevServerOptions> for ephemeral_server::TemporalDevServerConfig { .port(test_server_options.port()) .db_filename(options.database_filename.to_option_string()) .ui(options.ui) + .ui_port(if options.ui_port == 0 { + None + } else { + Some(options.ui_port) + }) .log(( options.log_format.to_string(), options.log_level.to_string(), diff --git a/src/Temporalio/Testing/WorkflowEnvironmentStartLocalOptions.cs b/src/Temporalio/Testing/WorkflowEnvironmentStartLocalOptions.cs index 6e3db018..8e0c4e28 100644 --- a/src/Temporalio/Testing/WorkflowEnvironmentStartLocalOptions.cs +++ b/src/Temporalio/Testing/WorkflowEnvironmentStartLocalOptions.cs @@ -21,6 +21,11 @@ public class WorkflowEnvironmentStartLocalOptions : Client.TemporalClientConnect /// public bool UI { get; set; } + /// + /// Gets or sets a value for the UI port to use if is true. + /// + public int UIPort { get; set; } + /// /// Gets or sets search attributes registered on the dev server on start. ///