Module: Protobuf

Defined in:
lib/protobuf.rb,
lib/protobuf/cli.rb,
lib/protobuf/enum.rb,
lib/protobuf/field.rb,
lib/protobuf/logger.rb,
lib/protobuf/statsd.rb,
lib/protobuf/decoder.rb,
lib/protobuf/encoder.rb,
lib/protobuf/message.rb,
lib/protobuf/rpc/env.rb,
lib/protobuf/version.rb,
lib/protobuf/rpc/stat.rb,
lib/protobuf/lifecycle.rb,
lib/protobuf/rpc/error.rb,
lib/protobuf/wire_type.rb,
lib/protobuf/deprecator.rb,
lib/protobuf/exceptions.rb,
lib/protobuf/optionable.rb,
lib/protobuf/rpc/buffer.rb,
lib/protobuf/rpc/client.rb,
lib/protobuf/rpc/rpc.pb.rb,
lib/protobuf/rpc/server.rb,
lib/protobuf/rpc/service.rb,
lib/protobuf/rpc/connector.rb,
lib/protobuf/code_generator.rb,
lib/protobuf/message/fields.rb,
lib/protobuf/rpc/middleware.rb,
lib/protobuf/generators/base.rb,
lib/protobuf/field/base_field.rb,
lib/protobuf/field/bool_field.rb,
lib/protobuf/field/enum_field.rb,
lib/protobuf/field/bytes_field.rb,
lib/protobuf/field/field_array.rb,
lib/protobuf/field/float_field.rb,
lib/protobuf/field/int32_field.rb,
lib/protobuf/field/int64_field.rb,
lib/protobuf/field/double_field.rb,
lib/protobuf/field/sint32_field.rb,
lib/protobuf/field/sint64_field.rb,
lib/protobuf/field/string_field.rb,
lib/protobuf/field/uint32_field.rb,
lib/protobuf/field/uint64_field.rb,
lib/protobuf/field/varint_field.rb,
lib/protobuf/rpc/connectors/zmq.rb,
lib/protobuf/field/fixed32_field.rb,
lib/protobuf/field/fixed64_field.rb,
lib/protobuf/field/integer_field.rb,
lib/protobuf/field/message_field.rb,
lib/protobuf/rpc/connectors/base.rb,
lib/protobuf/rpc/connectors/http.rb,
lib/protobuf/rpc/service_filters.rb,
lib/protobuf/field/sfixed32_field.rb,
lib/protobuf/field/sfixed64_field.rb,
lib/protobuf/generators/printable.rb,
lib/protobuf/rpc/servers/zmq/util.rb,
lib/protobuf/message/serialization.rb,
lib/protobuf/rpc/connectors/common.rb,
lib/protobuf/rpc/connectors/socket.rb,
lib/protobuf/rpc/middleware/logger.rb,
lib/protobuf/rpc/middleware/runner.rb,
lib/protobuf/rpc/middleware/statsd.rb,
lib/protobuf/rpc/service_directory.rb,
lib/protobuf/rpc/error/client_error.rb,
lib/protobuf/rpc/error/server_error.rb,
lib/protobuf/rpc/servers/zmq/broker.rb,
lib/protobuf/rpc/servers/zmq/server.rb,
lib/protobuf/rpc/servers/zmq/worker.rb,
lib/protobuf/rpc/servers/zmq_runner.rb,
lib/protobuf/rpc/service_dispatcher.rb,
lib/protobuf/rpc/servers/http/server.rb,
lib/protobuf/rpc/servers/http_runner.rb,
lib/protobuf/rpc/dynamic_discovery.pb.rb,
lib/protobuf/generators/enum_generator.rb,
lib/protobuf/generators/file_generator.rb,
lib/protobuf/rpc/servers/socket/server.rb,
lib/protobuf/rpc/servers/socket/worker.rb,
lib/protobuf/rpc/servers/socket_runner.rb,
lib/protobuf/field/signed_integer_field.rb,
lib/protobuf/generators/field_generator.rb,
lib/protobuf/generators/group_generator.rb,
lib/protobuf/generators/message_generator.rb,
lib/protobuf/generators/service_generator.rb,
lib/protobuf/generators/extension_generator.rb,
lib/protobuf/rpc/middleware/request_decoder.rb,
lib/protobuf/rpc/middleware/response_encoder.rb,
lib/protobuf/rpc/middleware/exception_handler.rb

Defined Under Namespace

Modules: Deprecator, Field, Generators, Optionable, Rpc, Socketrpc, WireType Classes: CLI, CodeGenerator, Decoder, DuplicateFieldNameError, Encoder, Enum, Error, FieldNotDefinedError, InvalidWireType, Lifecycle, Logger, Message, NotInitializedError, SerializationError, Statsd, TagCollisionError

Constant Summary collapse

CONNECTORS =

See Protobuf#connector_type documentation.

[ :socket, :zmq, :http ].freeze
DEFAULT_CONNECTOR =

Default is Socket as it has no external dependencies.

:socket
VERSION =
'3.2.0'

Class Method Summary collapse

Class Method Details

.client_hostObject

Client Host

Default: hostname of the system

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



27
28
29
# File 'lib/protobuf.rb', line 27

def self.client_host
  @_client_host ||= `hostname`.chomp
end

.client_host=(host) ⇒ Object



31
32
33
# File 'lib/protobuf.rb', line 31

def self.client_host=(host)
  @_client_host = host
end

.connector_typeObject

Connector Type

Default: socket

Symbol value which denotes the type of connector to use during client requests to an RPC server.



41
42
43
# File 'lib/protobuf.rb', line 41

def self.connector_type
  @_connector_type ||= DEFAULT_CONNECTOR
end

.connector_type=(type) ⇒ Object

Raises:

  • (ArgumentError)


45
46
47
48
# File 'lib/protobuf.rb', line 45

def self.connector_type=(type)
  raise ArgumentError, 'Invalid connector type given' unless CONNECTORS.include?(type)
  @_connector_type = type
end

.gc_pause_server_request=(value) ⇒ Object



63
64
65
# File 'lib/protobuf.rb', line 63

def self.gc_pause_server_request=(value)
  @_gc_pause_server_request = !!value
end

.gc_pause_server_request?Boolean

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.

Returns:

  • (Boolean)


58
59
60
61
# 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


82
83
84
# File 'lib/protobuf.rb', line 82

def self.print_deprecation_warnings=(value)
  @_print_deprecation_warnings = !!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['PB_IGNORE_DEPRECATIONS'] to a non-empty value.

The rpc_server option will override the ENV setting.

Returns:

  • (Boolean)


77
78
79
80
# File 'lib/protobuf.rb', line 77

def self.print_deprecation_warnings?
  return @_print_deprecation_warnings unless @_print_deprecation_warnings.nil?
  self.print_deprecation_warnings = ENV.key?('PB_IGNORE_DEPRECATIONS') ? false : true
end