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
-
#append_server_errors_to_trailing_metadata ⇒ Boolean
If true, will append all server error information into the trailing metadata in the response from the server.
-
#backtrace_limit ⇒ Integer
The limit of lines to use in backtraces returned.
-
#backtrace_on_error ⇒ Boolean
If true, will return the backtrace on any errors in servers in the trailing metadata.
-
#controllers_path ⇒ String
The relative path from root_path to locate Gruf Controllers in.
- #default_channel_credentials ⇒ NilClass, ...
-
#default_client_host ⇒ String
The default host for all new Gruf::Client objects to use as their target host.
-
#error_metadata_key ⇒ Symbol
The metadata key to use for error messages sent back in trailing metadata.
-
#error_serializer ⇒ NilClass|::Gruf::Serializers::Errors::Base
The error serializer to use for error messages sent back in trailing metadata.
- #event_listener_proc ⇒ NilClass, Proc
-
#grpc_logger ⇒ Logger
The logger to use with GRPC’s core logger (which logs plaintext).
-
#hooks ⇒ ::Gruf::Hooks::Registry
A registry of Gruf hooks for the server.
-
#interceptors ⇒ ::Gruf::Interceptors::Registry
A registry of Gruf server interceptors.
-
#internal_error_message ⇒ String
If use_exception_message is false, this message will be used instead as a replacement.
-
#logger ⇒ Logger
The logger class for Gruf-based logging.
-
#root_path ⇒ String
The root path for your application.
-
#rpc_server_options ⇒ Hash
A hash of RPC options for GRPC server configuration.
-
#server_binding_url ⇒ String
The full hostname:port that the gRPC server should bind to.
-
#server_options ⇒ Hash
A hash of options to pass to the server instance.
-
#services ⇒ Array<Class>
An array of services to serve with this Gruf server.
-
#ssl_crt_file ⇒ String
If use_ssl is true, the relative path from the root_path to the CRT file for the server.
-
#ssl_key_file ⇒ String
If use_ssl is true, the relative path from the root_path to the key file for the server.
-
#synchronized_client_internal_cache_expiry ⇒ Integer
Internal cache expiry period (in seconds) for the SynchronizedClient.
-
#use_default_interceptors ⇒ Boolean
If true, will use the default ActiveRecord and Timer interceptors for servers.
-
#use_exception_message ⇒ String
If true, will pass the actual exception message from the error in a server.
-
#use_ssl ⇒ Boolean
If true, will setup the server to use TLS.
Class Method Summary collapse
-
.extended(base) ⇒ Object
Whenever this is extended into a class, setup the defaults.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Gruf::Configuration
Yield self for ruby-style initialization.
-
#options ⇒ Hash
Return the current configuration options as a Hash.
-
#reset ⇒ Hash
Set the default configuration onto the extended class.
Instance Attribute Details
#append_server_errors_to_trailing_metadata ⇒ Boolean
Returns 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_limit ⇒ Integer
Returns 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_error ⇒ Boolean
Returns 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_path ⇒ String
Returns 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_credentials ⇒ NilClass, ...
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_host ⇒ String
Returns 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_key ⇒ Symbol
Returns 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_serializer ⇒ NilClass|::Gruf::Serializers::Errors::Base
Returns 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_proc ⇒ NilClass, Proc
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_logger ⇒ Logger
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.
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.
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.
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_message ⇒ String
Returns 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 |
#logger ⇒ Logger
Returns 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_path ⇒ String
Returns 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_options ⇒ Hash
Returns 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_url ⇒ String
Returns 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_options ⇒ Hash
Returns 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 |
#services ⇒ Array<Class>
Returns 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_file ⇒ String
Returns 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_file ⇒ String
Returns 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_expiry ⇒ Integer
Returns 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_interceptors ⇒ Boolean
Returns 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_message ⇒ String
Returns 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_ssl ⇒ Boolean
Returns 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
134 135 136 |
# File 'lib/gruf/configuration.rb', line 134 def configure yield self end |
#options ⇒ Hash
Return the current configuration options as a Hash
143 144 145 146 147 148 149 |
# File 'lib/gruf/configuration.rb', line 143 def opts = {} VALID_CONFIG_KEYS.each_key do |k| opts.merge!(k => send(k)) end opts end |
#reset ⇒ Hash
Set the default configuration onto the extended class
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. = { 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 end |