diff --git a/examples/spec/integration/await_workflow_result_spec.rb b/examples/spec/integration/await_workflow_result_spec.rb index 3b4f1e77..bf48b7b1 100644 --- a/examples/spec/integration/await_workflow_result_spec.rb +++ b/examples/spec/integration/await_workflow_result_spec.rb @@ -95,7 +95,9 @@ run_id = Temporal.start_workflow( LoopWorkflow, 2, # it continues as new if this arg is > 1 - { options: { workflow_id: workflow_id } }, + options: { + workflow_id: workflow_id, + }, ) expect do diff --git a/examples/spec/integration/continue_as_new_spec.rb b/examples/spec/integration/continue_as_new_spec.rb new file mode 100644 index 00000000..bbeef5ce --- /dev/null +++ b/examples/spec/integration/continue_as_new_spec.rb @@ -0,0 +1,44 @@ +require 'workflows/loop_workflow' + +describe LoopWorkflow do + it 'workflow continues as new into a new run' do + workflow_id = SecureRandom.uuid + memo = { + 'my-memo' => 'foo', + } + run_id = Temporal.start_workflow( + LoopWorkflow, + 2, # it continues as new if this arg is > 1 + options: { + workflow_id: workflow_id, + memo: memo, + }, + ) + + # First run will throw because it continued as new + next_run_id = nil + expect do + Temporal.await_workflow_result( + LoopWorkflow, + workflow_id: workflow_id, + run_id: run_id, + ) + end.to raise_error(Temporal::WorkflowRunContinuedAsNew) do |error| + next_run_id = error.new_run_id + end + + expect(next_run_id).to_not eq(nil) + + # Second run will not throw because it returns rather than continues as new. + final_result = Temporal.await_workflow_result( + LoopWorkflow, + workflow_id: workflow_id, + run_id: next_run_id, + ) + + expect(final_result[:count]).to eq(1) + + # memo should be copied to the next run automatically + expect(final_result[:memo]).to eq(memo) + end +end diff --git a/examples/spec/integration/metadata_workflow_spec.rb b/examples/spec/integration/metadata_workflow_spec.rb index a7d8ee1b..0e3c4099 100644 --- a/examples/spec/integration/metadata_workflow_spec.rb +++ b/examples/spec/integration/metadata_workflow_spec.rb @@ -7,13 +7,15 @@ workflow_id = 'task-queue-' + SecureRandom.uuid run_id = Temporal.start_workflow( subject, - { options: { workflow_id: workflow_id } }, + options: { workflow_id: workflow_id } ) + actual_result = Temporal.await_workflow_result( subject, workflow_id: workflow_id, run_id: run_id, ) + expect(actual_result.task_queue).to eq(Temporal.configuration.task_queue) end @@ -51,4 +53,39 @@ ) expect(Time.now - actual_result.run_started_at).to be_between(0, 30) end + + it 'gets memo from workflow execution info' do + workflow_id = 'memo_execution_test_wf-' + SecureRandom.uuid + run_id = Temporal.start_workflow(subject, options: { workflow_id: workflow_id, memo: { 'foo' => 'bar' } }) + + actual_result = Temporal.await_workflow_result( + subject, + workflow_id: workflow_id, + run_id: run_id, + ) + expect(actual_result.memo['foo']).to eq('bar') + + expect(Temporal.fetch_workflow_execution_info( + 'ruby-samples', workflow_id, nil + ).memo).to eq({ 'foo' => 'bar' }) + end + + it 'gets memo from workflow context with no memo' do + workflow_id = 'memo_context_no_memo_test_wf-' + SecureRandom.uuid + + run_id = Temporal.start_workflow( + subject, + options: { workflow_id: workflow_id } + ) + + actual_result = Temporal.await_workflow_result( + subject, + workflow_id: workflow_id, + run_id: run_id, + ) + expect(actual_result.memo).to eq({}) + expect(Temporal.fetch_workflow_execution_info( + 'ruby-samples', workflow_id, nil + ).memo).to eq({}) + end end diff --git a/examples/workflows/loop_workflow.rb b/examples/workflows/loop_workflow.rb index 5b1f5bfd..e10a9b30 100644 --- a/examples/workflows/loop_workflow.rb +++ b/examples/workflows/loop_workflow.rb @@ -8,6 +8,9 @@ def execute(count) return workflow.continue_as_new(count - 1) end - return count + return { + count: count, + memo: workflow.metadata.memo, + } end end diff --git a/examples/workflows/metadata_workflow.rb b/examples/workflows/metadata_workflow.rb index 4cdfab59..62f61703 100644 --- a/examples/workflows/metadata_workflow.rb +++ b/examples/workflows/metadata_workflow.rb @@ -2,4 +2,4 @@ class MetadataWorkflow < Temporal::Workflow def execute workflow.metadata end -end \ No newline at end of file +end diff --git a/lib/temporal/client.rb b/lib/temporal/client.rb index 9971a37c..28336acf 100644 --- a/lib/temporal/client.rb +++ b/lib/temporal/client.rb @@ -57,7 +57,8 @@ def start_workflow(workflow, *input, options: {}, **args) run_timeout: compute_run_timeout(execution_options), task_timeout: execution_options.timeouts[:task], workflow_id_reuse_policy: options[:workflow_id_reuse_policy], - headers: execution_options.headers + headers: execution_options.headers, + memo: execution_options.memo, ) else raise ArgumentError, 'If signal_input is provided, you must also provide signal_name' if signal_name.nil? @@ -73,6 +74,7 @@ def start_workflow(workflow, *input, options: {}, **args) task_timeout: execution_options.timeouts[:task], workflow_id_reuse_policy: options[:workflow_id_reuse_policy], headers: execution_options.headers, + memo: execution_options.memo, signal_name: signal_name, signal_input: signal_input ) @@ -119,7 +121,8 @@ def schedule_workflow(workflow, cron_schedule, *input, options: {}, **args) task_timeout: execution_options.timeouts[:task], workflow_id_reuse_policy: options[:workflow_id_reuse_policy], headers: execution_options.headers, - cron_schedule: cron_schedule + cron_schedule: cron_schedule, + memo: execution_options.memo ) response.run_id diff --git a/lib/temporal/concerns/payloads.rb b/lib/temporal/concerns/payloads.rb index 49af8f3f..3be276d2 100644 --- a/lib/temporal/concerns/payloads.rb +++ b/lib/temporal/concerns/payloads.rb @@ -21,6 +21,10 @@ def from_signal_payloads(payloads) from_payloads(payloads)&.first end + def from_payload_map(payload_map) + payload_map.map { |key, value| [key, from_payload(value)] }.to_h + end + def to_payloads(data) payload_converter.to_payloads(data) end @@ -41,6 +45,10 @@ def to_signal_payloads(data) to_payloads([data]) end + def to_payload_map(data) + data.transform_values(&method(:to_payload)) + end + private def payload_converter diff --git a/lib/temporal/connection/grpc.rb b/lib/temporal/connection/grpc.rb index 5b7e553b..70987e1e 100644 --- a/lib/temporal/connection/grpc.rb +++ b/lib/temporal/connection/grpc.rb @@ -81,7 +81,8 @@ def start_workflow_execution( task_timeout:, workflow_id_reuse_policy: nil, headers: nil, - cron_schedule: nil + cron_schedule: nil, + memo: nil ) request = Temporal::Api::WorkflowService::V1::StartWorkflowExecutionRequest.new( identity: identity, @@ -101,7 +102,10 @@ def start_workflow_execution( header: Temporal::Api::Common::V1::Header.new( fields: headers ), - cron_schedule: cron_schedule + cron_schedule: cron_schedule, + memo: Temporal::Api::Common::V1::Memo.new( + fields: to_payload_map(memo || {}) + ) ) if workflow_id_reuse_policy @@ -305,7 +309,8 @@ def signal_with_start_workflow_execution( headers: nil, cron_schedule: nil, signal_name:, - signal_input: + signal_input:, + memo: nil ) request = Temporal::Api::WorkflowService::V1::SignalWithStartWorkflowExecutionRequest.new( identity: identity, @@ -327,7 +332,10 @@ def signal_with_start_workflow_execution( ), cron_schedule: cron_schedule, signal_name: signal_name, - signal_input: to_signal_payloads(signal_input) + signal_input: to_signal_payloads(signal_input), + memo: Temporal::Api::Common::V1::Memo.new( + fields: to_payload_map(memo || {}) + ), ) if workflow_id_reuse_policy diff --git a/lib/temporal/connection/serializer/continue_as_new.rb b/lib/temporal/connection/serializer/continue_as_new.rb index 2d1e588c..db8259c6 100644 --- a/lib/temporal/connection/serializer/continue_as_new.rb +++ b/lib/temporal/connection/serializer/continue_as_new.rb @@ -19,7 +19,8 @@ def to_proto workflow_run_timeout: object.timeouts[:execution], workflow_task_timeout: object.timeouts[:task], retry_policy: Temporal::Connection::Serializer::RetryPolicy.new(object.retry_policy).to_proto, - header: serialize_headers(object.headers) + header: serialize_headers(object.headers), + memo: serialize_memo(object.memo) ) ) end @@ -31,6 +32,12 @@ def serialize_headers(headers) Temporal::Api::Common::V1::Header.new(fields: object.headers) end + + def serialize_memo(memo) + return unless memo + + Temporal::Api::Common::V1::Memo.new(fields: to_payload_map(memo)) + end end end end diff --git a/lib/temporal/connection/serializer/start_child_workflow.rb b/lib/temporal/connection/serializer/start_child_workflow.rb index 55312e50..ce1dc6ee 100644 --- a/lib/temporal/connection/serializer/start_child_workflow.rb +++ b/lib/temporal/connection/serializer/start_child_workflow.rb @@ -22,7 +22,8 @@ def to_proto workflow_run_timeout: object.timeouts[:run], workflow_task_timeout: object.timeouts[:task], retry_policy: Temporal::Connection::Serializer::RetryPolicy.new(object.retry_policy).to_proto, - header: serialize_headers(object.headers) + header: serialize_headers(object.headers), + memo: serialize_memo(object.memo), ) ) end @@ -34,6 +35,12 @@ def serialize_headers(headers) Temporal::Api::Common::V1::Header.new(fields: object.headers) end + + def serialize_memo(memo) + return unless memo + + Temporal::Api::Common::V1::Memo.new(fields: to_payload_map(memo)) + end end end end diff --git a/lib/temporal/execution_options.rb b/lib/temporal/execution_options.rb index 6fcaf371..182c4079 100644 --- a/lib/temporal/execution_options.rb +++ b/lib/temporal/execution_options.rb @@ -3,7 +3,7 @@ module Temporal class ExecutionOptions - attr_reader :name, :namespace, :task_queue, :retry_policy, :timeouts, :headers + attr_reader :name, :namespace, :task_queue, :retry_policy, :timeouts, :headers, :memo def initialize(object, options, defaults = nil) # Options are treated as overrides and take precedence @@ -13,6 +13,7 @@ def initialize(object, options, defaults = nil) @retry_policy = options[:retry_policy] || {} @timeouts = options[:timeouts] || {} @headers = options[:headers] || {} + @memo = options[:memo] || {} # For Temporal::Workflow and Temporal::Activity use defined values as the next option if has_executable_concern?(object) diff --git a/lib/temporal/metadata.rb b/lib/temporal/metadata.rb index 0617b784..df7165ea 100644 --- a/lib/temporal/metadata.rb +++ b/lib/temporal/metadata.rb @@ -20,7 +20,7 @@ def generate_activity_metadata(task, namespace) workflow_run_id: task.workflow_execution.run_id, workflow_id: task.workflow_execution.workflow_id, workflow_name: task.workflow_type.name, - headers: headers(task.header&.fields), + headers: from_payload_map(task.header&.fields || {}), heartbeat_details: from_details_payloads(task.heartbeat_details) ) end @@ -48,20 +48,11 @@ def generate_workflow_metadata(event, task_metadata) attempt: event.attributes.attempt, namespace: task_metadata.namespace, task_queue: event.attributes.task_queue.name, - headers: headers(event.attributes.header&.fields), + headers: from_payload_map(event.attributes.header&.fields || {}), run_started_at: event.timestamp, + memo: from_payload_map(event.attributes.memo&.fields || {}), ) end - - private - - def headers(fields) - result = {} - fields.each do |field, payload| - result[field] = from_payload(payload) - end - result - end end end end diff --git a/lib/temporal/metadata/workflow.rb b/lib/temporal/metadata/workflow.rb index 9e95acb1..f4715dde 100644 --- a/lib/temporal/metadata/workflow.rb +++ b/lib/temporal/metadata/workflow.rb @@ -3,9 +3,9 @@ module Temporal module Metadata class Workflow < Base - attr_reader :namespace, :id, :name, :run_id, :attempt, :task_queue, :headers, :run_started_at + attr_reader :namespace, :id, :name, :run_id, :attempt, :task_queue, :headers, :run_started_at, :memo - def initialize(namespace:, id:, name:, run_id:, attempt:, task_queue:, headers:, run_started_at:) + def initialize(namespace:, id:, name:, run_id:, attempt:, task_queue:, headers:, run_started_at:, memo:) @namespace = namespace @id = id @name = name @@ -14,6 +14,7 @@ def initialize(namespace:, id:, name:, run_id:, attempt:, task_queue:, headers:, @task_queue = task_queue @headers = headers @run_started_at = run_started_at + @memo = memo freeze end @@ -31,6 +32,7 @@ def to_h 'attempt' => attempt, 'task_queue' => task_queue, 'run_started_at' => run_started_at.to_f, + 'memo' => memo, } end end diff --git a/lib/temporal/testing/temporal_override.rb b/lib/temporal/testing/temporal_override.rb index dd67be7f..d44da24f 100644 --- a/lib/temporal/testing/temporal_override.rb +++ b/lib/temporal/testing/temporal_override.rb @@ -81,6 +81,7 @@ def start_locally(workflow, schedule, *input, **args) reuse_policy = options[:workflow_id_reuse_policy] || :allow_failed workflow_id = options[:workflow_id] || SecureRandom.uuid run_id = SecureRandom.uuid + memo = options[:memo] || {} if !allowed?(workflow_id, reuse_policy) raise Temporal::WorkflowExecutionAlreadyStartedFailure.new( @@ -101,6 +102,7 @@ def start_locally(workflow, schedule, *input, **args) attempt: 1, task_queue: execution_options.task_queue, run_started_at: Time.now, + memo: memo, headers: execution_options.headers ) context = Temporal::Testing::LocalWorkflowContext.new( diff --git a/lib/temporal/testing/workflow_override.rb b/lib/temporal/testing/workflow_override.rb index dab7472b..9d43f953 100644 --- a/lib/temporal/testing/workflow_override.rb +++ b/lib/temporal/testing/workflow_override.rb @@ -36,6 +36,7 @@ def execute_locally(*input) task_queue: 'unit-test-task-queue', headers: {}, run_started_at: Time.now, + memo: {}, ) context = Temporal::Testing::LocalWorkflowContext.new( execution, workflow_id, run_id, disabled_releases, metadata diff --git a/lib/temporal/workflow/command.rb b/lib/temporal/workflow/command.rb index 0f0d6ed9..8297abe9 100644 --- a/lib/temporal/workflow/command.rb +++ b/lib/temporal/workflow/command.rb @@ -3,8 +3,8 @@ class Workflow module Command # TODO: Move these classes into their own directories under workflow/command/* ScheduleActivity = Struct.new(:activity_type, :activity_id, :input, :namespace, :task_queue, :retry_policy, :timeouts, :headers, keyword_init: true) - StartChildWorkflow = Struct.new(:workflow_type, :workflow_id, :input, :namespace, :task_queue, :retry_policy, :timeouts, :headers, keyword_init: true) - ContinueAsNew = Struct.new(:workflow_type, :task_queue, :input, :timeouts, :retry_policy, :headers, keyword_init: true) + StartChildWorkflow = Struct.new(:workflow_type, :workflow_id, :input, :namespace, :task_queue, :retry_policy, :timeouts, :headers, :memo, keyword_init: true) + ContinueAsNew = Struct.new(:workflow_type, :task_queue, :input, :timeouts, :retry_policy, :headers, :memo, keyword_init: true) RequestActivityCancellation = Struct.new(:activity_id, keyword_init: true) RecordMarker = Struct.new(:name, :details, keyword_init: true) StartTimer = Struct.new(:timeout, :timer_id, keyword_init: true) diff --git a/lib/temporal/workflow/context.rb b/lib/temporal/workflow/context.rb index 18ec3c05..c06e4750 100644 --- a/lib/temporal/workflow/context.rb +++ b/lib/temporal/workflow/context.rb @@ -195,6 +195,12 @@ def continue_as_new(*input, **args) options = args.delete(:options) || {} input << args unless args.empty? + # If memo is not overridden, copy from current run + options_from_metadata = { + memo: metadata.memo, + } + options = options_from_metadata.merge(options) + execution_options = ExecutionOptions.new(workflow_class, options, config.default_execution_options) command = Command::ContinueAsNew.new( @@ -203,7 +209,8 @@ def continue_as_new(*input, **args) input: input, timeouts: execution_options.timeouts, retry_policy: execution_options.retry_policy, - headers: execution_options.headers + headers: execution_options.headers, + memo: execution_options.memo, ) schedule_command(command) completed! diff --git a/lib/temporal/workflow/execution_info.rb b/lib/temporal/workflow/execution_info.rb index 67cad260..46b8e4cb 100644 --- a/lib/temporal/workflow/execution_info.rb +++ b/lib/temporal/workflow/execution_info.rb @@ -1,6 +1,10 @@ +require 'temporal/concerns/payloads' + module Temporal class Workflow - class ExecutionInfo < Struct.new(:workflow, :workflow_id, :run_id, :start_time, :close_time, :status, :history_length, keyword_init: true) + class ExecutionInfo < Struct.new(:workflow, :workflow_id, :run_id, :start_time, :close_time, :status, :history_length, :memo, keyword_init: true) + extend Concerns::Payloads + RUNNING_STATUS = :RUNNING COMPLETED_STATUS = :COMPLETED FAILED_STATUS = :FAILED @@ -38,6 +42,7 @@ def self.generate_from(response) close_time: response.close_time&.to_time, status: API_STATUS_MAP.fetch(response.status), history_length: response.history_length, + memo: self.from_payload_map(response.memo.fields), ).freeze end diff --git a/spec/fabricators/grpc/memo_fabricator.rb b/spec/fabricators/grpc/memo_fabricator.rb new file mode 100644 index 00000000..6c9fd726 --- /dev/null +++ b/spec/fabricators/grpc/memo_fabricator.rb @@ -0,0 +1,7 @@ +Fabricator(:memo, from: Temporal::Api::Common::V1::Memo) do + fields do + Google::Protobuf::Map.new(:string, :message, Temporal::Api::Common::V1::Payload).tap do |m| + m['foo'] = Temporal.configuration.converter.to_payload('bar') + end + end +end diff --git a/spec/fabricators/grpc/workflow_execution_info_fabricator.rb b/spec/fabricators/grpc/workflow_execution_info_fabricator.rb index 296bde87..4f1d577e 100644 --- a/spec/fabricators/grpc/workflow_execution_info_fabricator.rb +++ b/spec/fabricators/grpc/workflow_execution_info_fabricator.rb @@ -5,4 +5,5 @@ close_time { Google::Protobuf::Timestamp.new.tap { |t| t.from_time(Time.now) } } status { Temporal::Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_COMPLETED } history_length { rand(100) } + memo { Fabricate(:memo) } end diff --git a/spec/fabricators/workflow_metadata_fabricator.rb b/spec/fabricators/workflow_metadata_fabricator.rb index 2b72b9e8..c32fd3e1 100644 --- a/spec/fabricators/workflow_metadata_fabricator.rb +++ b/spec/fabricators/workflow_metadata_fabricator.rb @@ -8,5 +8,6 @@ attempt 1 task_queue { Fabricate(:api_task_queue) } run_started_at { Time.now } + memo { {} } headers { {} } end diff --git a/spec/unit/lib/temporal/client_spec.rb b/spec/unit/lib/temporal/client_spec.rb index a0260f43..b52bd464 100644 --- a/spec/unit/lib/temporal/client_spec.rb +++ b/spec/unit/lib/temporal/client_spec.rb @@ -61,7 +61,8 @@ class TestStartWorkflow < Temporal::Workflow run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, - headers: {} + headers: {}, + memo: {} ) end @@ -73,7 +74,8 @@ class TestStartWorkflow < Temporal::Workflow name: 'test-workflow', namespace: 'test-namespace', task_queue: 'test-task-queue', - headers: { 'Foo' => 'Bar' } + headers: { 'Foo' => 'Bar' }, + memo: { 'MemoKey1' => 'MemoValue1' } } ) @@ -89,7 +91,8 @@ class TestStartWorkflow < Temporal::Workflow run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, - headers: { 'Foo' => 'Bar' } + headers: { 'Foo' => 'Bar' }, + memo: { 'MemoKey1' => 'MemoValue1' } ) end @@ -114,7 +117,8 @@ class TestStartWorkflow < Temporal::Workflow run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, - headers: {} + headers: {}, + memo: {} ) end @@ -133,7 +137,8 @@ class TestStartWorkflow < Temporal::Workflow run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, - headers: {} + headers: {}, + memo: {} ) end @@ -154,7 +159,8 @@ class TestStartWorkflow < Temporal::Workflow run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: :allow, - headers: {} + headers: {}, + memo: {} ) end end @@ -179,7 +185,8 @@ class TestStartWorkflow < Temporal::Workflow run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, - headers: {} + headers: {}, + memo: {} ) end end @@ -206,6 +213,7 @@ def expect_signal_with_start(expected_arguments, expected_signal_argument) execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, headers: {}, + memo: {}, signal_name: 'the question', signal_input: expected_signal_argument, ) @@ -285,7 +293,8 @@ def expect_signal_with_start(expected_arguments, expected_signal_argument) run_timeout: Temporal.configuration.timeouts[:run], execution_timeout: Temporal.configuration.timeouts[:execution], workflow_id_reuse_policy: nil, - headers: {} + memo: {}, + headers: {}, ) end end diff --git a/spec/unit/lib/temporal/connection/serializer/continue_as_new_spec.rb b/spec/unit/lib/temporal/connection/serializer/continue_as_new_spec.rb index fbb00623..4a7e90eb 100644 --- a/spec/unit/lib/temporal/connection/serializer/continue_as_new_spec.rb +++ b/spec/unit/lib/temporal/connection/serializer/continue_as_new_spec.rb @@ -5,10 +5,11 @@ describe 'to_proto' do it 'produces a protobuf' do command = Temporal::Workflow::Command::ContinueAsNew.new( - workflow_type: 'Test', - task_queue: 'Test', + workflow_type: 'my-workflow-type', + task_queue: 'my-task-queue', input: ['one', 'two'], - timeouts: Temporal.configuration.timeouts + timeouts: Temporal.configuration.timeouts, + memo: {'foo-memo': 'baz'}, ) result = described_class.new(command).to_proto @@ -17,6 +18,17 @@ expect(result.command_type).to eql( :COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION ) + expect(result.continue_as_new_workflow_execution_command_attributes).not_to be_nil + attribs = result.continue_as_new_workflow_execution_command_attributes + + expect(attribs.workflow_type.name).to eq('my-workflow-type') + + expect(attribs.task_queue.name).to eq('my-task-queue') + + expect(attribs.input.payloads[0].data).to eq('"one"') + expect(attribs.input.payloads[1].data).to eq('"two"') + + expect(attribs.memo.fields['foo-memo'].data).to eq('"baz"') end end end diff --git a/spec/unit/lib/temporal/grpc_client_spec.rb b/spec/unit/lib/temporal/grpc_client_spec.rb index 8349cc1e..a168c359 100644 --- a/spec/unit/lib/temporal/grpc_client_spec.rb +++ b/spec/unit/lib/temporal/grpc_client_spec.rb @@ -27,7 +27,8 @@ task_queue: 'test', execution_timeout: 0, run_timeout: 0, - task_timeout: 0 + task_timeout: 0, + memo: {} ) end.to raise_error(Temporal::WorkflowExecutionAlreadyStartedFailure) do |e| expect(e.run_id).to eql('baaf1d86-4459-4ecd-a288-47aeae55245d') diff --git a/spec/unit/lib/temporal/metadata/workflow_spec.rb b/spec/unit/lib/temporal/metadata/workflow_spec.rb index 4cc6fb74..be3f50b9 100644 --- a/spec/unit/lib/temporal/metadata/workflow_spec.rb +++ b/spec/unit/lib/temporal/metadata/workflow_spec.rb @@ -34,6 +34,7 @@ 'workflow_run_id' => subject.run_id, 'task_queue' => subject.task_queue, 'run_started_at' => subject.run_started_at.to_f, + 'memo' => subject.memo, }) end end diff --git a/spec/unit/lib/temporal/metadata_spec.rb b/spec/unit/lib/temporal/metadata_spec.rb index 7f5fb649..cd21fb76 100644 --- a/spec/unit/lib/temporal/metadata_spec.rb +++ b/spec/unit/lib/temporal/metadata_spec.rb @@ -56,6 +56,7 @@ expect(subject.id).to eq(task_metadata.workflow_id) expect(subject.attempt).to eq(event.attributes.attempt) expect(subject.headers).to eq({}) + expect(subject.memo).to eq({}) expect(subject.namespace).to eq(task_metadata.namespace) expect(subject.task_queue).to eq(event.attributes.task_queue.name) expect(subject.run_started_at).to eq(event.timestamp) diff --git a/spec/unit/lib/temporal/testing/local_workflow_context_spec.rb b/spec/unit/lib/temporal/testing/local_workflow_context_spec.rb index 1e7b8270..9397ef88 100644 --- a/spec/unit/lib/temporal/testing/local_workflow_context_spec.rb +++ b/spec/unit/lib/temporal/testing/local_workflow_context_spec.rb @@ -22,6 +22,7 @@ task_queue: task_queue, headers: {}, run_started_at: Time.now, + memo: {}, ) ) end diff --git a/spec/unit/lib/temporal/workflow/execution_info_spec.rb b/spec/unit/lib/temporal/workflow/execution_info_spec.rb index fbac5ee0..a064e8ba 100644 --- a/spec/unit/lib/temporal/workflow/execution_info_spec.rb +++ b/spec/unit/lib/temporal/workflow/execution_info_spec.rb @@ -14,6 +14,7 @@ expect(subject.close_time).to be_a(Time) expect(subject.status).to eq(:COMPLETED) expect(subject.history_length).to eq(api_info.history_length) + expect(subject.memo).to eq({ 'foo' => 'bar' }) end it 'freezes the info' do diff --git a/spec/unit/lib/temporal/workflow/executor_spec.rb b/spec/unit/lib/temporal/workflow/executor_spec.rb index dac7cbed..a74c3387 100644 --- a/spec/unit/lib/temporal/workflow/executor_spec.rb +++ b/spec/unit/lib/temporal/workflow/executor_spec.rb @@ -73,6 +73,7 @@ def execute attempt: event_attributes.attempt, task_queue: event_attributes.task_queue.name, run_started_at: workflow_started_event.event_time.to_time, + memo: {}, headers: {'Foo' => 'bar'} ) end