module Protobuf

Constants

Deprecation
FieldDeprecation
VERSION

Attributes

client_host[W]

Client Host

Default: ‘hostname` of the system

The name or address of the host to use during client RPC calls.

Public Class Methods

after_server_bind(&block) click to toggle source
# File lib/protobuf.rb, line 58
def self.after_server_bind(&block)
  ::ActiveSupport::Notifications.subscribe('after_server_bind') do |*args|
    block.call(*args)
  end
end
before_server_bind(&block) click to toggle source
# File lib/protobuf.rb, line 64
def self.before_server_bind(&block)
  ::ActiveSupport::Notifications.subscribe('before_server_bind') do |*args|
    block.call(*args)
  end
end
client_host() click to toggle source
# File lib/protobuf.rb, line 70
def self.client_host
  @client_host ||= Socket.gethostname
end
connector_type_class() click to toggle source
# File lib/protobuf.rb, line 74
def self.connector_type_class
  @connector_type_class ||= ::Protobuf::Rpc::Connectors::Socket
end
connector_type_class=(type_class) click to toggle source
# File lib/protobuf.rb, line 78
def self.connector_type_class=(type_class)
  @connector_type_class = type_class
end
deprecator() click to toggle source
# File lib/protobuf/deprecation.rb, line 87
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
field_deprecator() click to toggle source
# File lib/protobuf/deprecation.rb, line 94
def self.field_deprecator
  @field_deprecator ||= FieldDeprecation.new.tap do |deprecation|
    deprecation.silenced = ENV.key?('PB_IGNORE_DEPRECATIONS')
    deprecation.behavior = :stderr
  end
end
gc_pause_server_request=(value) click to toggle source
# File lib/protobuf.rb, line 95
def self.gc_pause_server_request=(value)
  @gc_pause_server_request = !!value
end
gc_pause_server_request?() click to toggle source

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 90
def self.gc_pause_server_request?
  return @gc_pause_server_request unless @gc_pause_server_request.nil?
  self.gc_pause_server_request = false
end
ignore_unknown_fields=(value) click to toggle source
# File lib/protobuf.rb, line 109
def self.ignore_unknown_fields=(value)
  @ignore_unknown_fields = !!value
end
ignore_unknown_fields?() click to toggle source

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 105
def self.ignore_unknown_fields?
  !defined?(@ignore_unknown_fields) || @ignore_unknown_fields
end
print_deprecation_warnings=(value) click to toggle source
print_deprecation_warnings?() click to toggle source

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.

Public Instance Methods

define_deprecated_methods(target_module, method_hash) click to toggle source
# File lib/protobuf/deprecation.rb, line 63
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
deprecate_method(target_module, method_name) click to toggle source
# File lib/protobuf/deprecation.rb, line 75
def deprecate_method(target_module, method_name)
  deprecate_methods(target_module, method_name => target_module)
end
deprecated_method_warning(method_name, target_module) click to toggle source
# File lib/protobuf/deprecation.rb, line 81
def deprecated_method_warning(method_name, target_module)
  "#{target_module.name}##{method_name} field usage is deprecated"
end
new(deprecation_horizon = nil, *) click to toggle source
# File lib/protobuf/deprecation.rb, line 54
def new(deprecation_horizon = nil, *)
  self.deprecation_horizon = deprecation_horizon if deprecation_horizon
  self
end