module Gruf::Configuration
Represents configuration settings for the system
Constants
- VALID_CONFIG_KEYS
Public Class Methods
extended(base)
click to toggle source
Whenever this is extended into a class, setup the defaults
# File lib/gruf/configuration.rb, line 63 def self.extended(base) if defined?(Rails) Gruf::Integrations::Rails::Railtie.config.before_initialize { base.reset } else base.reset end end
Public Instance Methods
configure() { |self| ... }
click to toggle source
Yield self for ruby-style initialization
@yields [Gruf::Configuration] The configuration object for gruf @return [Gruf::Configuration] The configuration object for gruf
# File lib/gruf/configuration.rb, line 77 def configure yield self end
options()
click to toggle source
Return the current configuration options as a Hash
@return [Hash] The configuration for gruf, represented as a Hash
# File lib/gruf/configuration.rb, line 86 def options opts = {} VALID_CONFIG_KEYS.each_key do |k| opts.merge!(k => send(k)) end opts end
reset()
click to toggle source
Set the default configuration onto the extended class
@return [Hash] options The reset options hash
# File lib/gruf/configuration.rb, line 99 def reset VALID_CONFIG_KEYS.each do |k, v| send("#{k}=", v) end self.interceptors = Gruf::Interceptors::Registry.new self.hooks = Gruf::Hooks::Registry.new self.root_path = Rails.root.to_s.chomp('/') if defined?(Rails) if defined?(Rails) && Rails.logger self.logger = Rails.logger else require 'logger' self.logger = ::Logger.new($stdout) end self.grpc_logger = logger if grpc_logger.nil? 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" if use_default_interceptors interceptors.use(Gruf::Interceptors::ActiveRecord::ConnectionReset) interceptors.use(Gruf::Interceptors::Instrumentation::OutputMetadataTimer) end options end
Private Instance Methods
environment()
click to toggle source
Automatically determine environment
@return [String] The current Ruby environment
# File lib/gruf/configuration.rb, line 130 def environment if defined?(Rails) Rails.env.to_s else (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development').to_s end end