New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata assumes it de-serializes to Symbol keys #436

Closed
xxx opened this Issue Aug 13, 2018 · 3 comments

Comments

2 participants
@xxx

xxx commented Aug 13, 2018

I'm moving to use JSON as the serializer for our events, since JSON is far more universal outside of the Ruby world, but Metadata#[]= assumes keys will be Symbols, and raises an ArgumentError if not. This isn't the case with events that are dumped to and loaded from JSON. Here are a couple specs that demonstrate this:

      let(:yaml_store) do
        RailsEventStore::Client.new(
          dispatcher: RailsEventStore::ActiveJobDispatcher.new(
            proxy_strategy: RailsEventStore::AsyncProxyStrategy::AfterCommit.new
          )
        )
      end

      let(:json_store) do
        RailsEventStore::Client.new(
          mapper: RubyEventStore::Mappers::Default.new(
            serializer: JSON
          ),
          dispatcher: RailsEventStore::ActiveJobDispatcher.new(
            proxy_strategy: RailsEventStore::AsyncProxyStrategy::AfterCommit.new
          )
        )
      end

      let(:event) { RailsEventStore::Event.new(data: {}, metadata: {}) }

      # fails, but should pass
      it 'publishes JSON-serialized events without error' do
        event_store = json_store
        event_store.publish event
        expect(event_store).to have_published(an_event(RailsEventStore::Event))
      end

      # passes as expected
      it 'publishes YAML-serialized events without error' do
        event_store = yaml_store
        event_store.publish event
        expect(event_store).to have_published(an_event(RailsEventStore::Event))
      end
@pawelpacana

This comment has been minimized.

Show comment
Hide comment
@pawelpacana

pawelpacana Aug 13, 2018

Member

Related: #367

Member

pawelpacana commented Aug 13, 2018

Related: #367

@xxx

This comment has been minimized.

Show comment
Hide comment
@xxx

xxx Aug 13, 2018

ah, duplicate. I couldn't find it for wahtever reason. Let's close this one.

xxx commented Aug 13, 2018

ah, duplicate. I couldn't find it for wahtever reason. Let's close this one.

@xxx xxx closed this Aug 13, 2018

@pawelpacana

This comment has been minimized.

Show comment
Hide comment
@pawelpacana

pawelpacana Aug 13, 2018

Member

No problem, I had this one in memory :)

Member

pawelpacana commented Aug 13, 2018

No problem, I had this one in memory :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment