Class: Temporalio::Testing::WorkflowEnvironment
- Inherits:
-
Object
- Object
- Temporalio::Testing::WorkflowEnvironment
- Defined in:
- lib/temporalio/testing/workflow_environment.rb
Overview
Test environment with a Temporal server for running workflows and more.
Instance Attribute Summary collapse
-
#client ⇒ Client
readonly
Client for the server.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client) ⇒ WorkflowEnvironment
constructor
Create workflow environment to an existing server with the given client.
-
#shutdown ⇒ Object
Shutdown this workflow environment.
Constructor Details
#initialize(client) ⇒ WorkflowEnvironment
Create workflow environment to an existing server with the given client.
114 115 116 |
# File 'lib/temporalio/testing/workflow_environment.rb', line 114 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Client (readonly)
Returns Client for the server.
14 15 16 |
# File 'lib/temporalio/testing/workflow_environment.rb', line 14 def client @client end |
Class Method Details
.start_local(namespace: 'default', data_converter: Converters::DataConverter.default, interceptors: [], logger: Logger.new($stdout, level: Logger::WARN), default_workflow_query_reject_condition: nil, ip: '127.0.0.1', port: nil, ui: false, runtime: Runtime.default, dev_server_existing_path: nil, dev_server_database_filename: nil, dev_server_log_format: 'pretty', dev_server_log_level: 'warn', dev_server_download_version: 'default', dev_server_download_dest_dir: nil, dev_server_extra_args: []) {|environment| ... } ⇒ WorkflowEnvironment, Object
Start a local dev server. This is a full Temporal dev server from the CLI that by default downloaded to tmp if not already present. The dev server is run as a child process. All options that start with dev_server_
are for this specific implementation and therefore are not stable and may be changed as the underlying implementation changes.
If a block is given it is passed the environment and the environment is shut down after. If a block is not given, the environment is returned and #shutdown needs to be called manually.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/temporalio/testing/workflow_environment.rb', line 50 def self.start_local( namespace: 'default', data_converter: Converters::DataConverter.default, interceptors: [], logger: Logger.new($stdout, level: Logger::WARN), default_workflow_query_reject_condition: nil, ip: '127.0.0.1', port: nil, ui: false, # rubocop:disable Naming/MethodParameterName runtime: Runtime.default, dev_server_existing_path: nil, dev_server_database_filename: nil, dev_server_log_format: 'pretty', dev_server_log_level: 'warn', dev_server_download_version: 'default', dev_server_download_dest_dir: nil, dev_server_extra_args: [] ) = Internal::Bridge::Testing::EphemeralServer::StartDevServerOptions.new( existing_path: dev_server_existing_path, sdk_name: 'sdk-ruby', sdk_version: VERSION, download_version: dev_server_download_version, download_dest_dir: dev_server_download_dest_dir, namespace:, ip:, port:, database_filename: dev_server_database_filename, ui:, log_format: dev_server_log_format, log_level: dev_server_log_level, extra_args: dev_server_extra_args ) core_server = Internal::Bridge::Testing::EphemeralServer.start_dev_server(runtime._core_runtime, ) # Try to connect, shutdown if we can't begin client = Client.connect( core_server.target, namespace, data_converter:, interceptors:, logger:, default_workflow_query_reject_condition:, runtime: ) server = Ephemeral.new(client, core_server) rescue StandardError core_server.shutdown raise end if block_given? begin yield server ensure server.shutdown end else server end end |
Instance Method Details
#shutdown ⇒ Object
Shutdown this workflow environment.
119 120 121 |
# File 'lib/temporalio/testing/workflow_environment.rb', line 119 def shutdown # Do nothing by default end |