v3.0.0.rc1
Pre-releaseA lot has changed leading up to the release of 3.0. For all the relevant changes,
see the closed pull requests and issues list in github.
Below is a high-level list of fixes, deprecations, breaking changes, and new APIs.
EventMachine is dead, Long live EventMachine
The EventMachine client and server have been removed from this gem. They code was far
too error prone and flawed to feasibly support going forward. It's recommended
to switch to the socket implementation (using PB_CLIENT_TYPE and PB_SERVER_TYPE of socket)
for a painless switchover. The ZMQ implementation is much more performant but
does have a dependency on libzmq.
Server Middlewares
The server/dispatcher stack has been converted to the Middleware pattern!
Exception handling (#162, #164), Request decoding (#160, #166), Response encoding (#161, #167),
Logging and stats (#163), and Method dispatch (#159) have all been extracted into their
own Middlewares to greatly simplify testing and further development of the server
stack, furthering our preparations for removing the socket implementations (zmq, socket)
into their own gems in version 4.0. Major props to @liveh2o for tackling this beast.
Bug Fixes
- Resolve DNS names (e.g. localhost) when using ZMQ server. [#46, reported by @reddshack]
- Switched to hash based value storage for messages to fix large field tag memory issues. [#118, #165]
Enum.fetchused to return an enum of any type if that is the value passed in. [#168]
Deprecations
!! NOTE: These deprecated methods will be removed in v3.1. !!
- Deprecated
BaseField#typein favor of#type_class. - Deprecated
Message.get_ext_field_by_namein favor of.get_extension_fieldor.get_field(name_or_tag, true). - Deprecated
Message.get_ext_field_by_tag,in favor of.get_extension_fieldor.get_field(name_or_tag, true). - Deprecated
Message.get_field_by_name,in favor of.get_field. - Deprecated
Message.get_field_by_tag,in favor of.get_field. - Deprecated
Enum.enum_by_valuein favor of.enum_for_tag. - Deprecated
Enum.name_by_valuein favor of.name_for_tag. - Deprecated
Enum.get_name_by_tagin favor of.name_for_tag. - Deprecated
Enum.value_by_namein favor of.enum_for_name. - Deprecated
Enum.valuesin favor of.enums. Beware that.enumsreturns an array where.valuesreturns a hash.
Use.all_tagsif you just need all the valid tag numbers. In other words, don't do this anymore:MyEnum.values.values.map(&:to_i).uniq.
Breaking Changes
- Require Active Support 3.2+. [#177]
- All files/classes relating to the EventMachine client and server are gone. Use
PB_CLIENT_TYPEandPB_SERVER_TYPEofsocketinstead. [#116] - Cleaned up the
Enumclass, deprecating/renaming most methods. tl;dr, just useMyEnum.fetch.
See #134 for more comprehensive documentation about which methods are going and away and which are being renamed. [#134] - Pulled
EnumValueintoEnum. TheEnumValueclass no longer exists. UseEnumfor type-checking instead. [#168]. - Removed previously deprecated
bin/rprotocexecutable. Useprotoc --ruby_out=...instead. [13fbdb9] - Removed previously deprecated
Service#rpcmethod. UseService#env#method_nameinstead. [f391294] - Changed the
Service#initializeto take anEnvobject instead of separate request, method, and client parameters. [6c61bf7] - Removed attribute readers for
Service#method_nameandService#client_host. UseService#envto get them instead. - Removed
lib/protobuf/message/message.rb. Uselib/protobuf/message.rbinstead. - Removed field getters from Message instances (e.g.
Message#get_field_by_name).
Use class-level getters instead (see Deprecations section). - Moved
lib/protobuf/message/decoder.rbtolib/protobuf/decoder.rb. The module is still namedProtobuf::Decoder. - Removed
Protobuf::Field::ExtensionFieldsclass. - Removed instance-level
maxandminmethods from all relevant Field classes (e.g. Int32Field, Uint64Field, etc).
Use class-level methods of the same names instead. [#176, 992eb05] PbError#to_responseno longer receives an argument, instead returning a newSocketrpc::Responseobject. [#147, @liveh2o]- The Server module has been stripped of almost all methods, now simply invokes the Middleware stack for each request. [#159, @liveh2o]
- Removed
Protobuf::PROTOC_VERSIONconstant now that the compiler supports any protoc version.
New APIs
- Added support for enum
allow_aliasoption. [#134] Enum.all_tagsreturns an array of unique tags. Use it to replaceEnum.values.values.map(&:to_i)(Enum.valuesis deprecated).Enum.enumsreturns an array of all defined enums for that class (including any aliased Enums).- Reinstated support for symbol primitive field types in generated Message code. [#170]
Message.get_fieldaccepts a second boolean parameter (default false) to return an extension field if found. [#169]- Mirror existing
Decoder#decode_from(stream)withEncoder#encode_to(stream). [#169] Servernow invokes the middleware stack for request handling. [#159, @liveh2o]- Added
protobuf:compileandprotobuf:cleanrake tasks. Simplyload 'protobuf/tasks/compile.rake'in your Rakefile (seecompile.rakefor arguments and usage). [#142, #143] - Add
Protobuf::Deprecatormodule to alias deprecated methods. [#165]