1010require 'temporalio/internal/bridge/testing'
1111require 'temporalio/internal/proto_utils'
1212require 'temporalio/runtime'
13+ require 'temporalio/search_attributes'
1314require 'temporalio/version'
1415
1516module Temporalio
@@ -34,8 +35,10 @@ class WorkflowEnvironment
3435 # @param default_workflow_query_reject_condition [WorkflowQueryRejectCondition, nil] Default rejection condition
3536 # for the client.
3637 # @param ip [String] IP to bind to.
37- # @param port [Integer, nil] Port to bind on, or + nil+ for random.
38+ # @param port [Integer, nil] Port to bind on, or ` nil` for random.
3839 # @param ui [Boolean] If +true+, also starts the UI.
40+ # @param ui_port [Integer, nil] Port to bind on if `ui` is true, or `nil` for random.
41+ # @param search_attributes [Array<SearchAttributes::Key>] Search attributes to make available on start.
3942 # @param runtime [Runtime] Runtime for the server and client.
4043 # @param dev_server_existing_path [String, nil] Existing CLI path to use instead of downloading and caching to
4144 # tmp.
@@ -62,6 +65,8 @@ def self.start_local(
6265 ip : '127.0.0.1' ,
6366 port : nil ,
6467 ui : false , # rubocop:disable Naming/MethodParameterName
68+ ui_port : nil ,
69+ search_attributes : [ ] ,
6570 runtime : Runtime . default ,
6671 dev_server_existing_path : nil ,
6772 dev_server_database_filename : nil ,
@@ -72,6 +77,15 @@ def self.start_local(
7277 dev_server_extra_args : [ ] ,
7378 &
7479 )
80+ # Add search attribute args
81+ unless search_attributes . empty?
82+ dev_server_extra_args += search_attributes . flat_map do |key |
83+ raise 'Search attribute must be Key' unless key . is_a? ( SearchAttributes ::Key )
84+
85+ [ '--search-attribute' , "#{ key . name } =#{ SearchAttributes ::IndexedValueType ::PROTO_NAMES [ key . type ] } " ]
86+ end
87+ end
88+
7589 server_options = Internal ::Bridge ::Testing ::EphemeralServer ::StartDevServerOptions . new (
7690 existing_path : dev_server_existing_path ,
7791 sdk_name : 'sdk-ruby' ,
@@ -83,6 +97,7 @@ def self.start_local(
8397 port :,
8498 database_filename : dev_server_database_filename ,
8599 ui :,
100+ ui_port : ui ? ui_port : nil ,
86101 log_format : dev_server_log_format ,
87102 log_level : dev_server_log_level ,
88103 extra_args : dev_server_extra_args
0 commit comments