Class: SolrWrapper::Settings
- Inherits:
-
Delegator
- Object
- Delegator
- SolrWrapper::Settings
- Defined in:
- lib/solr_wrapper/settings.rb
Overview
Configuraton that comes from static and dynamic sources.
Instance Method Summary collapse
- #__getobj__ ⇒ Object (also: #static_config)
- #__setobj__(obj) ⇒ Object
- #default_download_url ⇒ Object
- #download_url ⇒ Object
-
#host ⇒ Object
Get the host this Solr instance is bound to.
-
#initialize(static_config) ⇒ Settings
constructor
A new instance of Settings.
- #instance_dir ⇒ Object
- #managed? ⇒ Boolean
-
#port ⇒ Object
Get the port this Solr instance is running at.
- #solr_binary ⇒ Object
- #solr_zip_path ⇒ Object
- #tmp_save_dir ⇒ Object
-
#url ⇒ Object
Get a (likely) URL to the solr instance.
- #version_file ⇒ Object
- #zookeeper_host ⇒ Object
- #zookeeper_port ⇒ Object
Constructor Details
#initialize(static_config) ⇒ Settings
Returns a new instance of Settings.
18 19 20 21 |
# File 'lib/solr_wrapper/settings.rb', line 18 def initialize(static_config) super @static_config = static_config end |
Instance Method Details
#__getobj__ ⇒ Object Also known as: static_config
8 9 10 |
# File 'lib/solr_wrapper/settings.rb', line 8 def __getobj__ @static_config # return object we are delegating to, required end |
#__setobj__(obj) ⇒ Object
14 15 16 |
# File 'lib/solr_wrapper/settings.rb', line 14 def __setobj__(obj) @static_config = obj end |
#default_download_url ⇒ Object
83 84 85 |
# File 'lib/solr_wrapper/settings.rb', line 83 def default_download_url static_config.mirror_url end |
#download_url ⇒ Object
61 62 63 64 |
# File 'lib/solr_wrapper/settings.rb', line 61 def download_url @download_url ||= static_config.url @download_url ||= default_download_url end |
#host ⇒ Object
Get the host this Solr instance is bound to
25 26 27 |
# File 'lib/solr_wrapper/settings.rb', line 25 def host '127.0.0.1' end |
#instance_dir ⇒ Object
52 53 54 55 |
# File 'lib/solr_wrapper/settings.rb', line 52 def instance_dir @instance_dir ||= static_config.instance_dir @instance_dir ||= File.join(tmpdir, File.basename(download_url, ".zip")) end |
#managed? ⇒ Boolean
57 58 59 |
# File 'lib/solr_wrapper/settings.rb', line 57 def managed? File.exist?(instance_dir) end |
#port ⇒ Object
Get the port this Solr instance is running at
36 37 38 39 |
# File 'lib/solr_wrapper/settings.rb', line 36 def port @port ||= static_config.port @port ||= random_open_port.to_s end |
#solr_binary ⇒ Object
75 76 77 |
# File 'lib/solr_wrapper/settings.rb', line 75 def solr_binary File.join(instance_dir, "bin", "solr") end |
#solr_zip_path ⇒ Object
66 67 68 69 |
# File 'lib/solr_wrapper/settings.rb', line 66 def solr_zip_path @solr_zip_path ||= static_config.solr_zip_path @solr_zip_path ||= default_solr_zip_path end |
#tmp_save_dir ⇒ Object
79 80 81 |
# File 'lib/solr_wrapper/settings.rb', line 79 def tmp_save_dir @tmp_save_dir ||= Dir.mktmpdir end |
#url ⇒ Object
Get a (likely) URL to the solr instance
48 49 50 |
# File 'lib/solr_wrapper/settings.rb', line 48 def url "http://#{host}:#{port}/solr/" end |
#version_file ⇒ Object
71 72 73 |
# File 'lib/solr_wrapper/settings.rb', line 71 def version_file static_config.version_file || File.join(instance_dir, "VERSION") end |
#zookeeper_host ⇒ Object
29 30 31 32 |
# File 'lib/solr_wrapper/settings.rb', line 29 def zookeeper_host @zookeeper_host ||= static_config.zookeeper_port @zookeeper_host ||= host end |
#zookeeper_port ⇒ Object
41 42 43 44 |
# File 'lib/solr_wrapper/settings.rb', line 41 def zookeeper_port @zookeeper_port ||= static_config.zookeeper_port @zookeeper_port ||= "#{port.to_i + 1000}" end |