Skip to content

Commit

Permalink
Don't suggest use of NULL serializer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fidel committed Jan 23, 2023
1 parent ce4f16e commit b7edb48
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down

0 comments on commit b7edb48

Please sign in to comment.