From b7edb48eb43b935b6026aa9609baa7b7cf9a038b Mon Sep 17 00:00:00 2001 From: Szymon Fiedler Date: Mon, 23 Jan 2023 15:50:14 +0100 Subject: [PATCH] Don't suggest use of NULL serializer It's better to rely on explicit serializer for data and metadata. So that we pass string values in a flat hash to sidekiq. Thus we suggest RubyEventStore::Serializers::YAML or simply JSON as a serializer, so 3rd party (sidekiq) won't decide on how to handle serialization/deserialization. There's an added benefit of doing so: serialization/deserialization would occur just once when using the same serializer for both scheduler and repository. --- .../spec/sidekiq_scheduler_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/ruby_event_store-sidekiq_scheduler/spec/sidekiq_scheduler_spec.rb b/contrib/ruby_event_store-sidekiq_scheduler/spec/sidekiq_scheduler_spec.rb index bfec117ce8..9b487b427f 100644 --- a/contrib/ruby_event_store-sidekiq_scheduler/spec/sidekiq_scheduler_spec.rb +++ b/contrib/ruby_event_store-sidekiq_scheduler/spec/sidekiq_scheduler_spec.rb @@ -8,7 +8,7 @@ module RubyEventStore before(:each) { MyAsyncHandler.reset } it_behaves_like :scheduler, SidekiqScheduler.new(serializer: RubyEventStore::Serializers::YAML) - it_behaves_like :scheduler, SidekiqScheduler.new(serializer: RubyEventStore::NULL) + it_behaves_like :scheduler, SidekiqScheduler.new(serializer: JSON) let(:event) do TimeEnrichment.with(Event.new(event_id: "83c3187f-84f6-4da7-8206-73af5aca7cc8"), timestamp: Time.utc(2019, 9, 30)) @@ -18,27 +18,27 @@ module RubyEventStore describe "#verify" do specify do - scheduler = SidekiqScheduler.new(serializer: RubyEventStore::NULL) + scheduler = SidekiqScheduler.new(serializer: JSON) proper_handler = Class.new { include Sidekiq::Worker } expect(scheduler.verify(proper_handler)).to eq(true) end specify do - scheduler = SidekiqScheduler.new(serializer: RubyEventStore::NULL) + scheduler = SidekiqScheduler.new(serializer: JSON) some_class = Class.new expect(scheduler.verify(some_class)).to eq(false) end specify do - scheduler = SidekiqScheduler.new(serializer: RubyEventStore::NULL) + scheduler = SidekiqScheduler.new(serializer: JSON) expect(scheduler.verify(Sidekiq::Worker)).to eq(false) end specify do - scheduler = SidekiqScheduler.new(serializer: RubyEventStore::NULL) + scheduler = SidekiqScheduler.new(serializer: JSON) expect(scheduler.verify(Object.new)).to eq(false) end end