module Protobuf
Constants
- CONNECTORS
See Protobuf#connector_type documentation.
- DEFAULT_CONNECTOR
Default is Socket as it has no external dependencies.
- 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
Connector Type
Default: socket
Symbol value which denotes the type of connector to use during client requests to an RPC server.
# File lib/protobuf.rb, line 41 def self.connector_type @connector_type ||= DEFAULT_CONNECTOR end
# File lib/protobuf.rb, line 45 def self.connector_type=(type) fail ArgumentError, 'Invalid connector type given' unless CONNECTORS.include?(type) @connector_type = type end
# File lib/protobuf/deprecation.rb, line 81 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 88 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 63 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 58 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 77 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 73 def self.ignore_unknown_fields? !defined?(@ignore_unknown_fields) || @ignore_unknown_fields end
# File lib/protobuf/deprecation.rb, line 109 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 105 def self.print_deprecation_warnings? !field_deprecator.silenced end
Public Instance Methods
# File lib/protobuf/deprecation.rb, line 57 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 69 def deprecate_method(target_module, method_name) deprecate_methods(target_module, method_name => target_module) end
# File lib/protobuf/deprecation.rb, line 75 def deprecated_method_warning(method_name, target_module) "#{target_module.name}##{method_name} field usage is deprecated" end
# File lib/protobuf/deprecation.rb, line 48 def new(deprecation_horizon = nil, *) self.deprecation_horizon = deprecation_horizon if deprecation_horizon self end