Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dynflow/executors/sidekiq/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
config[:semi_reliable_fetch] = true
Sidekiq::ReliableFetch.setup_reliable_fetch!(config)
end
::Sidekiq.strict_args!(false)
::Sidekiq.strict_args!

module Dynflow
module Executors
Expand Down
3 changes: 2 additions & 1 deletion lib/dynflow/executors/sidekiq/serialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Sidekiq
# Module to prepend the Sidekiq job to handle the serialization
module Serialization
def self.serialize(value)
Dynflow.serializer.dump(value)
JSON.parse(JSON.dump(Dynflow.serializer.dump(value)))
end

def self.deserialize(value)
Expand All @@ -18,6 +18,7 @@ module WorkerExtension
# Overriding the Sidekiq entry method to perform additional serialization preparation
module ClassMethods
def client_push(opts)
opts = Utils::IndifferentHash.new(opts)
opts['args'] = opts['args'].map { |a| Serialization.serialize(a) }
super(opts)
end
Expand Down
8 changes: 7 additions & 1 deletion lib/dynflow/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def dump(object, options = {})
case object
when ::Array
object.collect { |v| dump(v) }
when ::Symbol
generate_other(object)
else
super
end
Expand All @@ -38,7 +40,9 @@ def parse_other(other, options = {})
end

if (type_name = other[ARBITRARY_TYPE_KEY] || other[ARBITRARY_TYPE_KEY.to_s])
if type_name == 'Time' && (time_str = other['value'])
if type_name == 'Symbol' && (val_str = other['value'])
return val_str.to_sym
elsif type_name == 'Time' && (time_str = other['value'])
return Serializable.send(:string_to_time, time_str)
end
type = Utils.constantize(type_name) rescue nil
Expand All @@ -53,6 +57,8 @@ def parse_other(other, options = {})

def generate_other(object, options = {})
hash = case
when object.is_a?(Symbol)
{ ARBITRARY_TYPE_KEY => 'Symbol', 'value' => object.to_s }
when object.respond_to?(:to_h)
object.to_h
when object.respond_to?(:to_hash)
Expand Down