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
-
#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).
-
#health_check_enabled ⇒ Boolean
If true, will load and register ‘Gruf::Controllers::HealthController` with the default gRPC health check to the loaded gRPC server.
- #health_check_hook ⇒ NilClass, Proc
-
#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.
- #development? ⇒ Boolean
-
#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.
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_limit ⇒ Integer
Returns 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_error ⇒ Boolean
Returns 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_path ⇒ String
Returns 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_credentials ⇒ NilClass, ...
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_host ⇒ String
Returns 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_key ⇒ Symbol
Returns 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_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.
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_proc ⇒ NilClass, Proc
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_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.
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_enabled ⇒ Boolean
Returns 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_hook ⇒ NilClass, Proc
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.
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.
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_message ⇒ String
Returns 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 |
#logger ⇒ Logger
Returns 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_path ⇒ String
Returns 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_options ⇒ Hash
Returns 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_url ⇒ String
Returns 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_options ⇒ Hash
Returns 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 |
#services ⇒ Array<Class>
Returns 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_file ⇒ String
Returns 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_file ⇒ String
Returns 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_expiry ⇒ Integer
Returns 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_interceptors ⇒ Boolean
Returns 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_message ⇒ String
Returns 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_ssl ⇒ Boolean
Returns 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
143 144 145 |
# File 'lib/gruf/configuration.rb', line 143 def configure yield self end |
#development? ⇒ Boolean
205 206 207 |
# File 'lib/gruf/configuration.rb', line 205 def development? environment == 'development' end |
#options ⇒ Hash
Return the current configuration options as a Hash
152 153 154 155 156 157 158 |
# File 'lib/gruf/configuration.rb', line 152 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
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. = { 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? end |