diff --git a/lib/temporal/activity/task_processor.rb b/lib/temporal/activity/task_processor.rb index ccc87e22..ef20780b 100644 --- a/lib/temporal/activity/task_processor.rb +++ b/lib/temporal/activity/task_processor.rb @@ -2,7 +2,6 @@ require 'temporal/error_handler' require 'temporal/errors' require 'temporal/activity/context' -require 'temporal/concerns/payloads' require 'temporal/connection/retryer' require 'temporal/connection' require 'temporal/metric_keys' diff --git a/lib/temporal/concerns/payloads.rb b/lib/temporal/concerns/payloads.rb deleted file mode 100644 index d7a79c4b..00000000 --- a/lib/temporal/concerns/payloads.rb +++ /dev/null @@ -1,87 +0,0 @@ -module Temporal - module Concerns - module Payloads - def from_payloads(payloads) - payloads = payload_codec.decodes(payloads) - payload_converter.from_payloads(payloads) - end - - def from_payload(payload) - payload = payload_codec.decode(payload) - payload_converter.from_payload(payload) - end - - def from_payload_map_without_codec(payload_map) - payload_map.map { |key, value| [key, payload_converter.from_payload(value)] }.to_h - end - - def from_result_payloads(payloads) - from_payloads(payloads)&.first - end - - def from_details_payloads(payloads) - from_payloads(payloads)&.first - end - - def from_signal_payloads(payloads) - from_payloads(payloads)&.first - end - - def from_query_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) - payloads = payload_converter.to_payloads(data) - payload_codec.encodes(payloads) - end - - def to_payload(data) - payload = payload_converter.to_payload(data) - payload_codec.encode(payload) - end - - def to_payload_map_without_codec(data) - # skips the payload_codec step because search attributes don't use this pipeline - data.transform_values do |value| - payload_converter.to_payload(value) - end - end - - def to_result_payloads(data) - to_payloads([data]) - end - - def to_details_payloads(data) - to_payloads([data]) - end - - def to_signal_payloads(data) - to_payloads([data]) - end - - def to_query_payloads(data) - to_payloads([data]) - end - - def to_payload_map(data) - data.transform_values(&method(:to_payload)) - end - - private - - def payload_converter - # TODO: Temporary fix, should fo away before the PR - Temporal.configuration.converter.send(:converter) - end - - def payload_codec - Temporal.configuration.payload_codec - end - end - end -end diff --git a/lib/temporal/connection/grpc.rb b/lib/temporal/connection/grpc.rb index e64567b3..5392f62a 100644 --- a/lib/temporal/connection/grpc.rb +++ b/lib/temporal/connection/grpc.rb @@ -15,7 +15,6 @@ require 'temporal/connection/serializer/backfill' require 'temporal/connection/serializer/schedule' require 'temporal/connection/serializer/workflow_id_reuse_policy' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/complete_workflow.rb b/lib/temporal/connection/serializer/complete_workflow.rb index 61441903..8eaa3ed4 100644 --- a/lib/temporal/connection/serializer/complete_workflow.rb +++ b/lib/temporal/connection/serializer/complete_workflow.rb @@ -1,5 +1,4 @@ require 'temporal/connection/serializer/base' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/continue_as_new.rb b/lib/temporal/connection/serializer/continue_as_new.rb index f9d4d999..989ff2a9 100644 --- a/lib/temporal/connection/serializer/continue_as_new.rb +++ b/lib/temporal/connection/serializer/continue_as_new.rb @@ -1,6 +1,5 @@ require 'temporal/connection/serializer/base' require 'temporal/connection/serializer/retry_policy' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/failure.rb b/lib/temporal/connection/serializer/failure.rb index 64727458..2d17e949 100644 --- a/lib/temporal/connection/serializer/failure.rb +++ b/lib/temporal/connection/serializer/failure.rb @@ -1,5 +1,4 @@ require 'temporal/connection/serializer/base' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/query_answer.rb b/lib/temporal/connection/serializer/query_answer.rb index bbf08b40..0c98b010 100644 --- a/lib/temporal/connection/serializer/query_answer.rb +++ b/lib/temporal/connection/serializer/query_answer.rb @@ -1,5 +1,4 @@ require 'temporal/connection/serializer/base' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/record_marker.rb b/lib/temporal/connection/serializer/record_marker.rb index 71c68973..99fddb8c 100644 --- a/lib/temporal/connection/serializer/record_marker.rb +++ b/lib/temporal/connection/serializer/record_marker.rb @@ -1,5 +1,4 @@ require 'temporal/connection/serializer/base' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/schedule_action.rb b/lib/temporal/connection/serializer/schedule_action.rb index 77e747f6..b79942be 100644 --- a/lib/temporal/connection/serializer/schedule_action.rb +++ b/lib/temporal/connection/serializer/schedule_action.rb @@ -1,5 +1,4 @@ require "temporal/connection/serializer/base" -require "temporal/concerns/payloads" module Temporal module Connection diff --git a/lib/temporal/connection/serializer/schedule_activity.rb b/lib/temporal/connection/serializer/schedule_activity.rb index 1f804f28..b3640639 100644 --- a/lib/temporal/connection/serializer/schedule_activity.rb +++ b/lib/temporal/connection/serializer/schedule_activity.rb @@ -1,6 +1,5 @@ require 'temporal/connection/serializer/base' require 'temporal/connection/serializer/retry_policy' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/signal_external_workflow.rb b/lib/temporal/connection/serializer/signal_external_workflow.rb index 525a3c02..ff229ddb 100644 --- a/lib/temporal/connection/serializer/signal_external_workflow.rb +++ b/lib/temporal/connection/serializer/signal_external_workflow.rb @@ -1,5 +1,4 @@ require 'temporal/connection/serializer/base' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/start_child_workflow.rb b/lib/temporal/connection/serializer/start_child_workflow.rb index 5fbc68e7..dcb2fbf0 100644 --- a/lib/temporal/connection/serializer/start_child_workflow.rb +++ b/lib/temporal/connection/serializer/start_child_workflow.rb @@ -1,7 +1,6 @@ require 'temporal/connection/serializer/base' require 'temporal/connection/serializer/retry_policy' require 'temporal/connection/serializer/workflow_id_reuse_policy' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/connection/serializer/upsert_search_attributes.rb b/lib/temporal/connection/serializer/upsert_search_attributes.rb index 7c7d89c7..b1b0395a 100644 --- a/lib/temporal/connection/serializer/upsert_search_attributes.rb +++ b/lib/temporal/connection/serializer/upsert_search_attributes.rb @@ -1,5 +1,4 @@ require 'temporal/connection/serializer/base' -require 'temporal/concerns/payloads' module Temporal module Connection diff --git a/lib/temporal/metadata.rb b/lib/temporal/metadata.rb index 09f2bc61..5439029f 100644 --- a/lib/temporal/metadata.rb +++ b/lib/temporal/metadata.rb @@ -2,7 +2,6 @@ require 'temporal/metadata/activity' require 'temporal/metadata/workflow' require 'temporal/metadata/workflow_task' -require 'temporal/concerns/payloads' module Temporal module Metadata diff --git a/lib/temporal/workflow/execution_info.rb b/lib/temporal/workflow/execution_info.rb index f183cc32..77a27332 100644 --- a/lib/temporal/workflow/execution_info.rb +++ b/lib/temporal/workflow/execution_info.rb @@ -1,4 +1,3 @@ -require 'temporal/concerns/payloads' require 'temporal/workflow/status' module Temporal diff --git a/lib/temporal/workflow/state_manager.rb b/lib/temporal/workflow/state_manager.rb index 9d78de35..c90ed3de 100644 --- a/lib/temporal/workflow/state_manager.rb +++ b/lib/temporal/workflow/state_manager.rb @@ -4,7 +4,6 @@ require 'temporal/workflow/command_state_machine' require 'temporal/workflow/history/event_target' require 'temporal/workflow/history/size' -require 'temporal/concerns/payloads' require 'temporal/workflow/errors' require 'temporal/workflow/sdk_flags' require 'temporal/workflow/signal' diff --git a/spec/fabricators/grpc/activity_task_fabricator.rb b/spec/fabricators/grpc/activity_task_fabricator.rb index 6d2a531d..82e0886f 100644 --- a/spec/fabricators/grpc/activity_task_fabricator.rb +++ b/spec/fabricators/grpc/activity_task_fabricator.rb @@ -6,7 +6,7 @@ activity_id { SecureRandom.uuid } task_token { |attrs| attrs[:task_token] || SecureRandom.uuid } activity_type { Fabricate(:api_activity_type) } - input { Temporal.configuration.converter.to_payloads(nil) } + input { TEST_CONVERTER.to_payloads(nil) } workflow_type { Fabricate(:api_workflow_type) } workflow_execution { Fabricate(:api_workflow_execution) } current_attempt_scheduled_time { Google::Protobuf::Timestamp.new.tap { |t| t.from_time(Time.now) } } @@ -15,7 +15,7 @@ current_attempt_scheduled_time { Google::Protobuf::Timestamp.new.tap { |t| t.from_time(Time.now) } } header do |attrs| fields = (attrs[:headers] || {}).each_with_object({}) do |(field, value), h| - h[field] = Temporal.configuration.converter.to_payload(value) + h[field] = TEST_CONVERTER.to_payload(value) end Temporalio::Api::Common::V1::Header.new(fields: fields) end diff --git a/spec/fabricators/grpc/application_failure_fabricator.rb b/spec/fabricators/grpc/application_failure_fabricator.rb index b2dc327a..95089cb7 100644 --- a/spec/fabricators/grpc/application_failure_fabricator.rb +++ b/spec/fabricators/grpc/application_failure_fabricator.rb @@ -1,5 +1,3 @@ -require 'temporal/concerns/payloads' - # Simulates Temporal::Connection::Serializer::Failure Fabricator(:api_application_failure, from: Temporalio::Api::Failure::V1::Failure) do transient :error_class, :backtrace diff --git a/spec/fabricators/grpc/history_event_fabricator.rb b/spec/fabricators/grpc/history_event_fabricator.rb index abf4b866..ad9a55e8 100644 --- a/spec/fabricators/grpc/history_event_fabricator.rb +++ b/spec/fabricators/grpc/history_event_fabricator.rb @@ -1,5 +1,4 @@ require 'securerandom' -require 'temporal/concerns/payloads' Fabricator(:api_history_event, from: Temporalio::Api::History::V1::HistoryEvent) do event_id { 1 } diff --git a/spec/fabricators/grpc/memo_fabricator.rb b/spec/fabricators/grpc/memo_fabricator.rb index 38f764f2..cf499c8a 100644 --- a/spec/fabricators/grpc/memo_fabricator.rb +++ b/spec/fabricators/grpc/memo_fabricator.rb @@ -1,7 +1,7 @@ Fabricator(:memo, from: Temporalio::Api::Common::V1::Memo) do fields do Google::Protobuf::Map.new(:string, :message, Temporalio::Api::Common::V1::Payload).tap do |m| - m['foo'] = Temporal.configuration.converter.to_payload('bar') + m['foo'] = TEST_CONVERTER.to_payload('bar') end end end diff --git a/spec/fabricators/grpc/search_attributes_fabricator.rb b/spec/fabricators/grpc/search_attributes_fabricator.rb index 16a33675..1e98516e 100644 --- a/spec/fabricators/grpc/search_attributes_fabricator.rb +++ b/spec/fabricators/grpc/search_attributes_fabricator.rb @@ -1,7 +1,7 @@ Fabricator(:search_attributes, from: Temporalio::Api::Common::V1::SearchAttributes) do indexed_fields do Google::Protobuf::Map.new(:string, :message, Temporalio::Api::Common::V1::Payload).tap do |m| - m['foo'] = Temporal.configuration.converter.to_payload('bar') + m['foo'] = TEST_CONVERTER.to_payload('bar') end end end diff --git a/spec/fabricators/grpc/workflow_query_fabricator.rb b/spec/fabricators/grpc/workflow_query_fabricator.rb index 024cdd59..f8831d49 100644 --- a/spec/fabricators/grpc/workflow_query_fabricator.rb +++ b/spec/fabricators/grpc/workflow_query_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:api_workflow_query, from: Temporalio::Api::Query::V1::WorkflowQuery) do query_type { 'state' } - query_args { Temporal.configuration.converter.to_payloads(['']) } + query_args { TEST_CONVERTER.to_payloads(['']) } end diff --git a/spec/unit/lib/temporal/connection/serializer/query_answer_spec.rb b/spec/unit/lib/temporal/connection/serializer/query_answer_spec.rb index eebbb957..5e912206 100644 --- a/spec/unit/lib/temporal/connection/serializer/query_answer_spec.rb +++ b/spec/unit/lib/temporal/connection/serializer/query_answer_spec.rb @@ -1,6 +1,5 @@ require 'temporal/connection/serializer/query_failure' require 'temporal/workflow/query_result' -require 'temporal/concerns/payloads' describe Temporal::Connection::Serializer::QueryAnswer do let(:converter) do