Module: Protobuf

Defined in:
lib/protobuf.rb,
lib/protobuf/cli.rb,
lib/protobuf/enum.rb,
lib/protobuf/field.rb,
lib/protobuf/varint.rb,
lib/protobuf/decoder.rb,
lib/protobuf/encoder.rb,
lib/protobuf/logging.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/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/deprecation.rb,
lib/protobuf/rpc/service.rb,
lib/protobuf/varint_pure.rb,
lib/protobuf/code_generator.rb,
lib/protobuf/message/fields.rb,
lib/protobuf/rpc/middleware.rb,
lib/protobuf/rpc/rpc_method.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/field_hash.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/ping.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/socket.rb,
lib/protobuf/rpc/middleware/logger.rb,
lib/protobuf/rpc/middleware/runner.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/servers/zmq_runner.rb,
lib/protobuf/rpc/service_dispatcher.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/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/option_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,
lib/protobuf/field/base_field_object_definitions.rb

Defined Under Namespace

Modules: Field, Generators, Logging, Optionable, Rpc, Socketrpc, VarintPure, WireType Classes: CLI, CodeGenerator, Decoder, Deprecation, DeprecationBase, DuplicateFieldNameError, Encoder, Enum, Error, FieldDeprecation, FieldNotDefinedError, InvalidWireType, Lifecycle, Message, NotInitializedError, SerializationError, TagCollisionError, Varint

Constant Summary collapse

VERSION =

rubocop:disable Style/MutableConstant

'3.10.8'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.client_hostObject



69
70
71
# File 'lib/protobuf.rb', line 69

def self.client_host
  @client_host ||= Socket.gethostname
end

Class Method Details

.after_server_bind(&block) ⇒ Object



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

.before_server_bind(&block) ⇒ Object



63
64
65
66
67
# 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

.connector_type_classObject



73
74
75
# File 'lib/protobuf.rb', line 73

def self.connector_type_class
  @connector_type_class ||= ::Protobuf::Rpc::Connectors::Socket
end

.connector_type_class=(type_class) ⇒ Object



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

def self.connector_type_class=(type_class)
  @connector_type_class = type_class
end

.deprecatorObject



86
87
88
89
90
91
# 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

.field_deprecatorObject



93
94
95
96
97
98
# 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

.gc_pause_server_request=(value) ⇒ Object



94
95
96
# File 'lib/protobuf.rb', line 94

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)


89
90
91
92
# 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

.ignore_unknown_fields=(value) ⇒ Object



108
109
110
# File 'lib/protobuf.rb', line 108

def self.ignore_unknown_fields=(value)
  @ignore_unknown_fields = !!value
end

.ignore_unknown_fields?Boolean

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.

Returns:

  • (Boolean)


104
105
106
# File 'lib/protobuf.rb', line 104

def self.ignore_unknown_fields?
  !defined?(@ignore_unknown_fields) || @ignore_unknown_fields
end


114
115
116
# 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['PB_IGNORE_DEPRECATIONS'] to a non-empty value.

The rpc_server option will override the ENV setting.

Returns:

  • (Boolean)


110
111
112
# File 'lib/protobuf/deprecation.rb', line 110

def self.print_deprecation_warnings?
  !field_deprecator.silenced
end