Class: SolrWrapper::Settings

Inherits:
Delegator
  • Object
show all
Defined in:
lib/solr_wrapper/settings.rb

Overview

Configuraton that comes from static and dynamic sources.

Instance Method Summary collapse

Constructor Details

#initialize(static_config) ⇒ Settings

Returns a new instance of Settings.



17
18
19
20
# File 'lib/solr_wrapper/settings.rb', line 17

def initialize(static_config)
  super
  @static_config = static_config
end

Instance Method Details

#__getobj__Object Also known as: static_config



7
8
9
# File 'lib/solr_wrapper/settings.rb', line 7

def __getobj__
  @static_config # return object we are delegating to, required
end

#__setobj__(obj) ⇒ Object



13
14
15
# File 'lib/solr_wrapper/settings.rb', line 13

def __setobj__(obj)
  @static_config = obj
end

#base_urlObject



45
46
47
# File 'lib/solr_wrapper/settings.rb', line 45

def base_url
  "http://#{host}:#{port}/"
end

#default_download_urlObject



86
87
88
# File 'lib/solr_wrapper/settings.rb', line 86

def default_download_url
  static_config.mirror_url
end

#download_urlObject



64
65
66
67
# File 'lib/solr_wrapper/settings.rb', line 64

def download_url
  @download_url ||= static_config.url
  @download_url ||= default_download_url
end

#downloaded_artifact_pathObject



69
70
71
72
# File 'lib/solr_wrapper/settings.rb', line 69

def downloaded_artifact_path
  @downloaded_artifact_path ||= static_config.artifact_path
  @downloaded_artifact_path ||= default_solr_artifact_path
end

#hostObject

Get the host this Solr instance is bound to



24
25
26
# File 'lib/solr_wrapper/settings.rb', line 24

def host
  '127.0.0.1'
end

#instance_dirObject



55
56
57
58
# File 'lib/solr_wrapper/settings.rb', line 55

def instance_dir
  @instance_dir ||= static_config.instance_dir
  @instance_dir ||= File.join(tmpdir, File.basename(download_url, ".tgz"))
end

#managed?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/solr_wrapper/settings.rb', line 60

def managed?
  File.exist?(instance_dir)
end

#portObject

Get the port this Solr instance is running at



35
36
37
38
# File 'lib/solr_wrapper/settings.rb', line 35

def port
  @port ||= static_config.port
  @port ||= random_open_port.to_s
end

#solr_binaryObject



78
79
80
# File 'lib/solr_wrapper/settings.rb', line 78

def solr_binary
  File.join(instance_dir, "bin", "solr")
end

#tmp_save_dirObject



82
83
84
# File 'lib/solr_wrapper/settings.rb', line 82

def tmp_save_dir
  @tmp_save_dir ||= Dir.mktmpdir
end

#urlObject

Get a (likely) URL to the solr instance



51
52
53
# File 'lib/solr_wrapper/settings.rb', line 51

def url
  "#{base_url}solr/"
end

#version_fileObject



74
75
76
# File 'lib/solr_wrapper/settings.rb', line 74

def version_file
  static_config.version_file || File.join(instance_dir, "VERSION")
end

#zookeeper_hostObject



28
29
30
31
# File 'lib/solr_wrapper/settings.rb', line 28

def zookeeper_host
  @zookeeper_host ||= static_config.zookeeper_port
  @zookeeper_host ||= host
end

#zookeeper_portObject



40
41
42
43
# File 'lib/solr_wrapper/settings.rb', line 40

def zookeeper_port
  @zookeeper_port ||= static_config.zookeeper_port
  @zookeeper_port ||= "#{port.to_i + 1000}"
end