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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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)


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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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.



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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.



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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)



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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.



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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

#health_check_enabledBoolean

Returns If true, will load and register ‘Gruf::Controllers::HealthController` with the default gRPC health check to the loaded gRPC server.

Returns:

  • (Boolean)

    If true, will load and register ‘Gruf::Controllers::HealthController` with the default gRPC health check to the loaded gRPC server



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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

#health_check_hookNilClass, Proc

Returns:

  • (NilClass)
  • (Proc)

    If set, will call this in the gRPC health check. It is required to return a ‘::Grpc::Health::V1::HealthCheckResponse` object in this proc to indicate the health of the server.



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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:



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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:



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



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
114
115
116
117
118
119
120
121
122
# File 'lib/gruf/configuration.rb', line 87

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: '0.0.0.0:9001',
  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,
  health_check_enabled: false,
  health_check_hook: 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



129
130
131
132
133
134
135
# File 'lib/gruf/configuration.rb', line 129

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:



143
144
145
# File 'lib/gruf/configuration.rb', line 143

def configure
  yield self
end

#development?Boolean

Returns:

  • (Boolean)


205
206
207
# File 'lib/gruf/configuration.rb', line 205

def development?
  environment == 'development'
end

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)

    The configuration for gruf, represented as a Hash



152
153
154
155
156
157
158
# File 'lib/gruf/configuration.rb', line 152

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



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/gruf/configuration.rb', line 165

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"
  cp = ::ENV.fetch('GRUF_CONTROLLERS_PATH', 'app/rpc').to_s
  self.controllers_path = root_path.to_s.empty? ? cp : "#{root_path}/#{cp}"
  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).to_i,
    poll_period: ::ENV.fetch('GRPC_SERVER_POLL_PERIOD', GRPC::RpcServer::DEFAULT_POLL_PERIOD).to_i,
    connect_md_proc: nil,
    server_args: {}
  }
  self.use_default_interceptors = ::ENV.fetch('GRUF_USE_DEFAULT_INTERCEPTORS', 1).to_i.positive?

  if use_default_interceptors
    if defined?(::Rails)
      interceptors.use(::Gruf::Interceptors::Rails::Reloader, reloader: Rails.application.reloader)
    end
    interceptors.use(::Gruf::Interceptors::ActiveRecord::ConnectionReset)
    interceptors.use(::Gruf::Interceptors::Instrumentation::OutputMetadataTimer)
  end
  self.health_check_enabled = ::ENV.fetch('GRUF_HEALTH_CHECK_ENABLED', 0).to_i.positive?
  options
end