module Protobuf
Constants
- Deprecation
- FieldDeprecation
- VERSION
Attributes
Client Host
Default: `hostname` of the system
The name or address of the host to use during client RPC calls.
Public Class Methods
# File lib/protobuf.rb, line 57 def self.after_server_bind(&block) ::ActiveSupport::Notifications.subscribe('after_server_bind') do |*args| block.call(*args) end end
# File lib/protobuf.rb, line 63 def self.before_server_bind(&block) ::ActiveSupport::Notifications.subscribe('before_server_bind') do |*args| block.call(*args) end end
# File lib/protobuf.rb, line 69 def self.client_host @client_host ||= Socket.gethostname end
# File lib/protobuf.rb, line 73 def self.connector_type_class @connector_type_class ||= ::Protobuf::Rpc::Connectors::Socket end
# File lib/protobuf.rb, line 77 def self.connector_type_class=(type_class) @connector_type_class = type_class end
# File lib/protobuf/deprecation.rb, line 86 def self.deprecator @deprecator ||= Deprecation.new('4.0', to_s).tap do |deprecation| deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS') deprecation.behavior = :stderr end end
# File lib/protobuf/deprecation.rb, line 93 def self.field_deprecator @field_deprecator ||= FieldDeprecation.new.tap do |deprecation| deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS') deprecation.behavior = :stderr end end
# File lib/protobuf.rb, line 94 def self.gc_pause_server_request=(value) @gc_pause_server_request = !!value end
GC Pause during server requests
Default: false
Boolean value to tell the server to disable the Garbage Collector when handling an rpc request. Once the request is completed, the GC is enabled again. This optomization provides a huge boost in speed to rpc requests.
# File lib/protobuf.rb, line 89 def self.gc_pause_server_request? return @gc_pause_server_request unless @gc_pause_server_request.nil? self.gc_pause_server_request = false end
# File lib/protobuf.rb, line 108 def self.ignore_unknown_fields=(value) @ignore_unknown_fields = !!value end
Permit unknown field on Message
initialization
Default: true
Simple boolean to define whether we want to permit unknown fields on Message
intialization; otherwise a ::Protobuf::FieldNotDefinedError
is thrown.
# File lib/protobuf.rb, line 104 def self.ignore_unknown_fields? !defined?(@ignore_unknown_fields) || @ignore_unknown_fields end
# File lib/protobuf/deprecation.rb, line 114 def self.print_deprecation_warnings=(value) field_deprecator.silenced = !value end
Print Deprecation
Warnings
Default: true
Simple boolean to define whether we want field deprecation warnings to be printed to stderr or not. The rpc_server has an option to set this value explicitly, or you can turn this option off by setting ENV to a non-empty value.
The rpc_server option will override the ENV setting.
# File lib/protobuf/deprecation.rb, line 110 def self.print_deprecation_warnings? !field_deprecator.silenced end
Public Instance Methods
# File lib/protobuf/deprecation.rb, line 62 def define_deprecated_methods(target_module, method_hash) target_module.module_eval do method_hash.each do |old_method, new_method| alias_method old_method, new_method end end deprecate_methods(target_module, method_hash) end
# File lib/protobuf/deprecation.rb, line 74 def deprecate_method(target_module, method_name) deprecate_methods(target_module, method_name => target_module) end
# File lib/protobuf/deprecation.rb, line 80 def deprecated_method_warning(method_name, target_module) "#{target_module.name}##{method_name} field usage is deprecated" end
# File lib/protobuf/deprecation.rb, line 53 def new(deprecation_horizon = nil, *) self.deprecation_horizon = deprecation_horizon if deprecation_horizon self end