-
Notifications
You must be signed in to change notification settings - Fork 34
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
Exclude default packers #55
base: master
Are you sure you want to change the base?
Conversation
- update deprecated function in plug_parser - setting up ability to override packers
@elcritch thanks for bringing this up for discussion. I think we can split it into 2 aspects:
In regards to 1. I'm not sure it should be solved via conditional compilation: can lead to nasty and obscure application bugs, it also does not really make possible the customization in the umbrella applications. For now I suggest we focus on solving 2. defimpl Msgpax.Packer, for: MyApp.Float32 do
def pack(%MyApp.Float32{value: value}) do
@protocol.pack_float32(value)
end
end What are your thoughts on this? |
Great, and I agree it'd be better to handle it without compile time logic. I'm doing it currently but it's fragile.
This would be the best option IMHO. It's much more elegant. Probably best to close this PR in favor of that issue. Not sure exactly what the API would look like?
The |
I've created #60 that describes the approach I have in mind. Perhaps this PR can be updated to implement that approach.
I see, I can imagine wrapping into a struct will be too bothersome when dealing with nesting and collections. |
a157d5d
to
bcec987
Compare
can't wait this feature to support custom Atom.
|
Adds the option to exclude a set of default packers. The use case for this is rare, but can allow people to customize behavior as wanted in a global fashion. In this case, I need to be able to set the float serialization type to float32. I started with a branch allowing just that, but this seemed to be better and could let someone override other default packers should they want to (say serialize maps to ordered list pairs or something odd).
The config options is:
config :msgpax, exclude_packers: [:atom, :map, ...]
.