Skip to content
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

Use MessageConverter in persistence strategies #153

Merged
merged 6 commits into from
May 30, 2018

Conversation

enumag
Copy link
Member

@enumag enumag commented May 10, 2018

I wanted to change the behavior how a message is serialized (I'm not using Message::payload()). In order to do so I was forced to implement a custom persistence strategy.

In my opinion it's not a responsibility of a PersistenceStrategy to do the serialization. And it's not a responsibility of a Message either in my setup.

Recently I found a MessageConverter interface in Prooph/Common and I believe the responsibility belongs there and so it should be used here in the persistence strategies. Then I could simply change the converter implementation.

Note: I would like to remove the payload method from Message interface later in another PR and move it to DomainMessage or a new MessageWithPayload interface.

@prolic
Copy link
Member

prolic commented May 10, 2018

Seems like a BC to me.

@enumag
Copy link
Member Author

enumag commented May 10, 2018

Well obviously. There is no way to do this without a BC break.

@coveralls
Copy link

coveralls commented May 10, 2018

Coverage Status

Coverage decreased (-0.4%) to 89.747% when pulling 1e8459e on enumag:message-converter into 54e3e44 on prooph:master.

@prolic
Copy link
Member

prolic commented May 10, 2018

ping @codeliner

@enumag
Copy link
Member Author

enumag commented May 10, 2018

Technically I could make the argument for persistence strategies nullable and create a fallback implementation if null. That way it would be fully backwards compatible. Should I implement it that way? Possibly with a deprecation if the argument is not provided?

EDIT: Done.

@enumag
Copy link
Member Author

enumag commented May 14, 2018

ping @prolic

@prolic
Copy link
Member

prolic commented May 23, 2018

ping @codeliner

/**
* @deprecated This class is used for backwards compatibility. It's recommended to use a different MessageConverter implementation such as \Prooph\Common\Messaging\NoOpMessageConverter.
*/
class CompatibilityMessageConverter implements MessageConverter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use NoOpMessageConverter directly? What is this class for? Why is it deprecated?

Copy link
Member Author

@enumag enumag May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's deprecated because such class does not belong to this package and is only here for BC.

NoOpMessageConverter should be located in prooph/common. It is already there but requires DomainMessage which is a slightly different case.

I can add the converter to prooph/common, use it here and remove this class - of course it will require increase in required prooph/common version which technically means losing BC with older prooph/common. Are you fine with that? If so, any tip for the class name since NoOpMessageConverter is already taken?

Or I can use the existing NoOpMessageConverter from prooph/common which is also a BC break because it requires DomainMessage.

Basically it depends on how far you want to go with the backwards compatibility. Currently this PR has full BC as requested.

@prolic
Copy link
Member

prolic commented May 23, 2018 via email

@enumag
Copy link
Member Author

enumag commented May 23, 2018

@prolic Done. There is still the issue that such converter doesn't really belong here. I think I'll add a copy to prooph/common later.

@prolic
Copy link
Member

prolic commented May 24, 2018

ping @codeliner, your thoughts?

@codeliner
Copy link
Member

LGTM

@prolic prolic self-assigned this May 30, 2018
@prolic prolic merged commit a49ef88 into prooph:master May 30, 2018
@prolic
Copy link
Member

prolic commented May 30, 2018

thanks @enumag

next release will be probably this weekend, still waiting for another PR to be finished

@enumag
Copy link
Member Author

enumag commented May 30, 2018

@prolic That's fine. I'm not in a hurry to use this anyway. Thank you!

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

Successfully merging this pull request may close these issues.

None yet

4 participants