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[RW]

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() click to toggle source

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
connector_type=(type) click to toggle source
# 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
deprecator() click to toggle source
# 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
field_deprecator() click to toggle source
# 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
gc_pause_server_request=(value) click to toggle source
# File lib/protobuf.rb, line 63
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 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
ignore_unknown_fields=(value) click to toggle source
# File lib/protobuf.rb, line 77
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 73
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 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
deprecate_method(target_module, method_name) click to toggle source
# File lib/protobuf/deprecation.rb, line 69
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 75
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 48
def new(deprecation_horizon = nil, *)
  self.deprecation_horizon = deprecation_horizon if deprecation_horizon
  self
end