Support :message_pack as message serializer - #47964
Conversation
There was a problem hiding this comment.
Rubocop flags this with Performance/StringInclude: Use String#include? instead of a regex match with literal-only pattern, but format is a symbol, not a string.
I could work around using format.to_s.include?("message_pack"), but I'm more inclined to disable the Performance/StringInclude rule, since this is valid code.
There was a problem hiding this comment.
format.start_with?("message_pack") could do the trick.
There was a problem hiding this comment.
Or just if format == :message_pack || format == :message_pack_allow_marshal. A bit longer but very explicit.
There was a problem hiding this comment.
My thinking was to require when format included any mention of message_pack because tests may not catch a missing require (due to previous tests performing the require). So if some :message_pack_* or :*_message_pack variant is added in the future, it would be covered. (I admit that may be overkill though.)
8e19f9d to
425d6a5
Compare
ca25e3d to
0c58701
Compare
This commit adds support for `:message_pack` as a serializer for `MessageEncryptor` and `MessageVerifier`, and, consequently, as an option for `config.active_support.message_serializer`. The `:message_pack` serializer is implemented via `ActiveSupport::Messages::SerializerWithFallback` and can fall back to deserializing with `AS::JSON`. Additionally, the `:marshal`, `:json`, and `:json_allow_marshal` serializers can now fall back to deserializing with `AS::MessagePack`. This commit also adds support for `:message_pack_allow_marshal` as a serializer, which can fall back to deserializing with `Marshal` as well as `AS::JSON`.
0c58701 to
af6d835
Compare
This covers rails#47770, rails#47964, rails#48103, and rails#48104, plus the follow-up changes to `ActiveSupport::Cache::Store` options from rails#48449 and rails#48451.
This commit adds support for
:message_packas a serializer forMessageEncryptorandMessageVerifier, and, consequently, as an option forconfig.active_support.message_serializer.The
:message_packserializer is implemented viaActiveSupport::Messages::SerializerWithFallbackand can fall back to deserializing withAS::JSON. Additionally, the:marshal,:json, and:json_allow_marshalserializers can now fall back to deserializing withAS::MessagePack.This commit also adds support for
:message_pack_allow_marshalas a serializer, which can fall back to deserializing withMarshalas well asAS::JSON.