Skip to content

Commit 5f529d8

Browse files
mostlyobviousfidel
andcommitted
Finally
Co-authored-by: Szymon Fiedler <[email protected]>
1 parent b308fca commit 5f529d8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

railseventstore.org/versioned_docs/version-2.17.0/advanced-topics/event-serialization-formats.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Serialization is needed not only when writing to and reading from storage, but a
3636

3737
```ruby
3838
Rails.configuration.event_store = RailsEventStore::Client.new(
39-
message_broker: RubyEventStore::Broker.new(
39+
message_broker: RubyEventStore::Broker.new(
4040
dispatcher: RubyEventStore::ComposedDispatcher.new(
4141
RailsEventStore::AfterCommitAsyncDispatcher.new(scheduler: ActiveJobScheduler.new(serializer: Marshal)),
4242
RubyEventStore::Dispatcher.new
@@ -71,25 +71,23 @@ Next, configure your event store client to the JSON client:
7171
Rails.configuration.event_store = RailsEventStore::JSONClient.new
7272
```
7373

74-
If you need additional configuration beyond the included JSON client, continue from here. In your `RailsEventStore::Client` initialization, set repository serialization to ` RailsEventStoreActiveRecord::EventRepository.new(serializer: RubyEventStore::NULL)`
74+
If you need additional configuration beyond the included JSON client, continue from here. In your `RailsEventStore::Client` initialization, set repository serialization to ` RailsEventStoreActiveRecord::EventRepository.new(serializer: JSON)`
7575

7676
```ruby
7777
# config/environments/*.rb
7878

7979
Rails.application.configure do
8080
config.to_prepare do
8181
Rails.configuration.event_store = RailsEventStore::Client.new(
82-
repository: RailsEventStoreActiveRecord::EventRepository.new(serializer: RubyEventStore::NULL)
82+
repository: RailsEventStoreActiveRecord::EventRepository.new(serializer: JSON)
8383
)
8484
end
8585
end
8686
```
8787

88-
Using the `RubyEventStore::NULL` serializer will prevent the event store from serializing the event data and metadata. This is necessary because the Active Record will handle serialization before putting the data into the database. And will do otherwise when reading. Database itself expect data to be json already.
89-
9088
<div class="px-4 py-1 text-blue-600 bg-blue-100 border-l-4 border-blue-500" role="alert">
9189
<p class="text-base font-bold">Note that <code>JSON</code> converts symbols to strings. Ensure your code accounts for this when retrieving events.</p>
92-
90+
9391
```ruby
9492
JSON.load(JSON.dump({foo: :bar}))
9593
=> {"foo"=>"bar"}

0 commit comments

Comments
 (0)