Class: Typesense::Configuration
- Inherits:
-
Object
- Object
- Typesense::Configuration
- Defined in:
- lib/typesense/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#connection_timeout_seconds ⇒ Object
Returns the value of attribute connection_timeout_seconds.
-
#healthcheck_interval_seconds ⇒ Object
Returns the value of attribute healthcheck_interval_seconds.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#nearest_node ⇒ Object
Returns the value of attribute nearest_node.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
-
#num_retries ⇒ Object
Returns the value of attribute num_retries.
-
#retry_interval_seconds ⇒ Object
Returns the value of attribute retry_interval_seconds.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/typesense/configuration.rb', line 9 def initialize( = {}) @nodes = [:nodes] || [] @nearest_node = [:nearest_node] @connection_timeout_seconds = [:connection_timeout_seconds] || [:timeout_seconds] || 10 @healthcheck_interval_seconds = [:healthcheck_interval_seconds] || 15 @num_retries = [:num_retries] || (@nodes.length + (@nearest_node.nil? ? 0 : 1)) || 3 @retry_interval_seconds = [:retry_interval_seconds] || 0.1 @api_key = [:api_key] @logger = [:logger] || Logger.new($stdout) @log_level = [:log_level] || Logger::WARN @logger.level = @log_level show_deprecation_warnings() validate! end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def api_key @api_key end |
#connection_timeout_seconds ⇒ Object
Returns the value of attribute connection_timeout_seconds.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def connection_timeout_seconds @connection_timeout_seconds end |
#healthcheck_interval_seconds ⇒ Object
Returns the value of attribute healthcheck_interval_seconds.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def healthcheck_interval_seconds @healthcheck_interval_seconds end |
#log_level ⇒ Object
Returns the value of attribute log_level.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def logger @logger end |
#nearest_node ⇒ Object
Returns the value of attribute nearest_node.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def nearest_node @nearest_node end |
#nodes ⇒ Object
Returns the value of attribute nodes.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def nodes @nodes end |
#num_retries ⇒ Object
Returns the value of attribute num_retries.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def num_retries @num_retries end |
#retry_interval_seconds ⇒ Object
Returns the value of attribute retry_interval_seconds.
7 8 9 |
# File 'lib/typesense/configuration.rb', line 7 def retry_interval_seconds @retry_interval_seconds end |
Instance Method Details
#validate! ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/typesense/configuration.rb', line 26 def validate! if @nodes.nil? || @nodes.empty? || @nodes.any? { |node| node_missing_parameters?(node) } raise Error::MissingConfiguration, 'Missing required configuration. Ensure that nodes[][:protocol], nodes[][:host] and nodes[][:port] are set.' end raise Error::MissingConfiguration, 'Missing required configuration. Ensure that api_key is set.' if @api_key.nil? end |