Module: Gruf::Configuration

Included in:
Gruf
Defined in:
lib/gruf/configuration.rb

Overview

Represents configuration settings for the system

Constant Summary collapse

VALID_CONFIG_KEYS =
{
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#append_server_errors_to_trailing_metadataBoolean

Returns If true, will append all server error information into the trailing metadata in the response from the server.

Returns:

  • (Boolean)

    If true, will append all server error information into the trailing metadata in the response from the server



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#backtrace_limitInteger

Returns The limit of lines to use in backtraces returned.

Returns:

  • (Integer)

    The limit of lines to use in backtraces returned



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#backtrace_on_errorBoolean

Returns If true, will return the backtrace on any errors in servers in the trailing metadata.

Returns:

  • (Boolean)

    If true, will return the backtrace on any errors in servers in the trailing metadata



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#controllers_pathString

Returns The relative path from root_path to locate Gruf Controllers in.

Returns:

  • (String)

    The relative path from root_path to locate Gruf Controllers in



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#default_channel_credentialsNilClass, ...

Returns:

  • (NilClass)
  • (Symbol)
  • (Hash)


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#default_client_hostString

Returns The default host for all new Gruf::Client objects to use as their target host.

Returns:

  • (String)

    The default host for all new Gruf::Client objects to use as their target host



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#error_metadata_keySymbol

Returns The metadata key to use for error messages sent back in trailing metadata.

Returns:

  • (Symbol)

    The metadata key to use for error messages sent back in trailing metadata.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#error_serializerNilClass|::Gruf::Serializers::Errors::Base

Returns The error serializer to use for error messages sent back in trailing metadata. Defaults to the base JSON serializer.

Returns:

  • (NilClass|::Gruf::Serializers::Errors::Base)

    The error serializer to use for error messages sent back in trailing metadata. Defaults to the base JSON serializer.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#event_listener_procNilClass, Proc

Returns:

  • (NilClass)
  • (Proc)

    If set, this will be used during GRPC events (such as pool exhaustions)



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#grpc_loggerLogger

Returns The logger to use with GRPC’s core logger (which logs plaintext). It is recommended to set this to an STDOUT logger and use a logging pipeline that can translate plaintext logs given GRPC’s unformatted logging.

Returns:

  • (Logger)

    The logger to use with GRPC’s core logger (which logs plaintext). It is recommended to set this to an STDOUT logger and use a logging pipeline that can translate plaintext logs given GRPC’s unformatted logging.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#hooks::Gruf::Hooks::Registry

Returns A registry of Gruf hooks for the server.

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#interceptors::Gruf::Interceptors::Registry

Returns A registry of Gruf server interceptors.

Returns:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#internal_error_messageString

Returns If use_exception_message is false, this message will be used instead as a replacement.

Returns:

  • (String)

    If use_exception_message is false, this message will be used instead as a replacement



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#loggerLogger

Returns The logger class for Gruf-based logging.

Returns:

  • (Logger)

    The logger class for Gruf-based logging



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#root_pathString

Returns The root path for your application.

Returns:

  • (String)

    The root path for your application



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#rpc_server_optionsHash

Returns A hash of RPC options for GRPC server configuration.

Returns:

  • (Hash)

    A hash of RPC options for GRPC server configuration



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#server_binding_urlString

Returns The full hostname:port that the gRPC server should bind to.

Returns:

  • (String)

    The full hostname:port that the gRPC server should bind to



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#server_optionsHash

Returns A hash of options to pass to the server instance.

Returns:

  • (Hash)

    A hash of options to pass to the server instance



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#servicesArray<Class>

Returns An array of services to serve with this Gruf server.

Returns:

  • (Array<Class>)

    An array of services to serve with this Gruf server



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#ssl_crt_fileString

Returns If use_ssl is true, the relative path from the root_path to the CRT file for the server.

Returns:

  • (String)

    If use_ssl is true, the relative path from the root_path to the CRT file for the server



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#ssl_key_fileString

Returns If use_ssl is true, the relative path from the root_path to the key file for the server.

Returns:

  • (String)

    If use_ssl is true, the relative path from the root_path to the key file for the server



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#synchronized_client_internal_cache_expiryInteger

Returns Internal cache expiry period (in seconds) for the SynchronizedClient.

Returns:

  • (Integer)

    Internal cache expiry period (in seconds) for the SynchronizedClient



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#use_default_interceptorsBoolean

Returns If true, will use the default ActiveRecord and Timer interceptors for servers.

Returns:

  • (Boolean)

    If true, will use the default ActiveRecord and Timer interceptors for servers



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#use_exception_messageString

Returns If true, will pass the actual exception message from the error in a server.

Returns:

  • (String)

    If true, will pass the actual exception message from the error in a server



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

#use_sslBoolean

Returns If true, will setup the server to use TLS.

Returns:

  • (Boolean)

    If true, will setup the server to use TLS



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/gruf/configuration.rb', line 80

VALID_CONFIG_KEYS = {
  root_path: '',
  server_binding_url: '0.0.0.0:9001',
  server_options: {},
  interceptors: nil,
  hooks: nil,
  default_channel_credentials: nil,
  default_client_host: '',
  use_ssl: false,
  ssl_crt_file: '',
  ssl_key_file: '',
  controllers_path: '',
  services: [],
  logger: nil,
  grpc_logger: nil,
  error_metadata_key: :'error-internal-bin',
  error_serializer: nil,
  append_server_errors_to_trailing_metadata: true,
  use_default_interceptors: true,
  backtrace_on_error: false,
  backtrace_limit: 10,
  use_exception_message: true,
  internal_error_message: 'Internal Server Error',
  event_listener_proc: nil,
  synchronized_client_internal_cache_expiry: 60,
  rpc_server_options: {
    pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
    max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
    poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
    pool_keep_alive: GRPC::Pool::DEFAULT_KEEP_ALIVE,
    connect_md_proc: nil,
    server_args: {}
  }.freeze
}.freeze

Class Method Details

.extended(base) ⇒ Object

Whenever this is extended into a class, setup the defaults



120
121
122
123
124
125
126
# File 'lib/gruf/configuration.rb', line 120

def self.extended(base)
  if defined?(::Rails)
    ::Gruf::Integrations::Rails::Railtie.config.before_initialize { base.reset }
  else
    base.reset
  end
end

Instance Method Details

#configure {|_self| ... } ⇒ Gruf::Configuration

Yield self for ruby-style initialization

Yields:

  • (_self)

Yield Parameters:

Returns:



134
135
136
# File 'lib/gruf/configuration.rb', line 134

def configure
  yield self
end

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)

    The configuration for gruf, represented as a Hash



143
144
145
146
147
148
149
# File 'lib/gruf/configuration.rb', line 143

def options
  opts = {}
  VALID_CONFIG_KEYS.each_key do |k|
    opts.merge!(k => send(k))
  end
  opts
end

#resetHash

Set the default configuration onto the extended class

Returns:

  • (Hash)

    options The reset options hash



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/gruf/configuration.rb', line 156

def reset
  VALID_CONFIG_KEYS.each do |k, v|
    send("#{k}=", v)
  end
  self.server_binding_url = "#{::ENV.fetch('GRPC_SERVER_HOST',
                                           '0.0.0.0')}:#{::ENV.fetch('GRPC_SERVER_PORT', 9_001)}"
  self.interceptors = ::Gruf::Interceptors::Registry.new
  self.hooks = ::Gruf::Hooks::Registry.new
  self.root_path = ::Rails.root.to_s.chomp('/') if defined?(::Rails)
  determine_loggers
  self.ssl_crt_file = "#{root_path}config/ssl/#{environment}.crt"
  self.ssl_key_file = "#{root_path}config/ssl/#{environment}.key"
  self.controllers_path = root_path.to_s.empty? ? 'app/rpc' : "#{root_path}/app/rpc"
  self.backtrace_on_error = ::ENV.fetch('GRPC_BACKTRACE_ON_ERROR', 0).to_i.positive?
  self.rpc_server_options = {
    max_waiting_requests: ::ENV.fetch('GRPC_SERVER_MAX_WAITING_REQUESTS',
                                      GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS).to_i,
    pool_size: ::ENV.fetch('GRPC_SERVER_POOL_SIZE', GRPC::RpcServer::DEFAULT_POOL_SIZE).to_i,
    pool_keep_alive: ::ENV.fetch('GRPC_SERVER_POOL_KEEP_ALIVE', GRPC::Pool::DEFAULT_KEEP_ALIVE),
    poll_period: ::ENV.fetch('GRPC_SERVER_POLL_PERIOD', GRPC::RpcServer::DEFAULT_POLL_PERIOD),
    connect_md_proc: nil,
    server_args: {}
  }
  if use_default_interceptors
    interceptors.use(::Gruf::Interceptors::ActiveRecord::ConnectionReset)
    interceptors.use(::Gruf::Interceptors::Instrumentation::OutputMetadataTimer)
  end
  options
end