Module: BoringServices
- Defined in:
- lib/boring_services.rb,
lib/boring_services/cli.rb,
lib/boring_services/secrets.rb,
lib/boring_services/version.rb,
lib/boring_services/installer.rb,
lib/boring_services/ssh_executor.rb,
lib/boring_services/configuration.rb,
lib/boring_services/services/base.rb,
lib/boring_services/health_checker.rb,
lib/boring_services/services/nginx.rb,
lib/boring_services/services/redis.rb,
lib/boring_services/service_locator.rb,
lib/boring_services/services/haproxy.rb,
lib/boring_services/services/memcached.rb,
lib/boring_services/generators/boring_services/install_generator.rb
Defined Under Namespace
Modules: Generators, Services Classes: CLI, Configuration, Error, HealthChecker, Installer, SSHExecutor, Secrets, ServiceLocator
Constant Summary collapse
- VERSION =
'0.8.1'.freeze
Class Method Summary collapse
-
.host_for(service, label) ⇒ Object
Generic: get host by exact label for any service.
-
.hosts_for(service) ⇒ Object
Generic: get all hosts for any service as hash { label => ip }.
-
.locator ⇒ Object
Service locator instance (cached).
-
.memcached_host(label) ⇒ Object
Get Memcached host by exact label.
-
.memcached_hosts ⇒ Object
Get all Memcached hosts as hash { label => private_ip }.
-
.memcached_port ⇒ Object
Get Memcached port.
-
.memcached_servers(label: nil) ⇒ Object
Get Memcached servers string (host:port,host:port).
-
.port_for(service) ⇒ Object
Generic: get port for any service.
-
.redis_host(label) ⇒ Object
Get Redis host by exact label.
-
.redis_hosts ⇒ Object
Get all Redis hosts as hash { label => private_ip }.
-
.redis_port ⇒ Object
Get Redis port.
-
.redis_url(label: nil, password: nil, db: 0) ⇒ Object
Build Redis URL for a label.
-
.reset_locator! ⇒ Object
Reset cached locator (useful for testing or config reload).
- .root ⇒ Object
- .status ⇒ Object
Class Method Details
.host_for(service, label) ⇒ Object
Generic: get host by exact label for any service
88 89 90 |
# File 'lib/boring_services.rb', line 88 def host_for(service, label) locator.host_by_label(service, label) end |
.hosts_for(service) ⇒ Object
Generic: get all hosts for any service as hash { label => ip }
83 84 85 |
# File 'lib/boring_services.rb', line 83 def hosts_for(service) locator.hosts_by_label(service) end |
.locator ⇒ Object
Service locator instance (cached)
31 32 33 |
# File 'lib/boring_services.rb', line 31 def locator @locator ||= ServiceLocator.new end |
.memcached_host(label) ⇒ Object
Get Memcached host by exact label
68 69 70 |
# File 'lib/boring_services.rb', line 68 def memcached_host(label) locator.host_by_label('memcached', label) end |
.memcached_hosts ⇒ Object
Get all Memcached hosts as hash { label => private_ip }
63 64 65 |
# File 'lib/boring_services.rb', line 63 def memcached_hosts locator.hosts_by_label('memcached') end |
.memcached_port ⇒ Object
Get Memcached port
73 74 75 |
# File 'lib/boring_services.rb', line 73 def memcached_port locator.port_for('memcached') || 11_211 end |
.memcached_servers(label: nil) ⇒ Object
Get Memcached servers string (host:port,host:port)
78 79 80 |
# File 'lib/boring_services.rb', line 78 def memcached_servers(label: nil) locator.memcached_servers(label: label) end |
.port_for(service) ⇒ Object
Generic: get port for any service
93 94 95 |
# File 'lib/boring_services.rb', line 93 def port_for(service) locator.port_for(service) end |
.redis_host(label) ⇒ Object
Get Redis host by exact label
48 49 50 |
# File 'lib/boring_services.rb', line 48 def redis_host(label) locator.host_by_label('redis', label) end |
.redis_hosts ⇒ Object
Get all Redis hosts as hash { label => private_ip }
43 44 45 |
# File 'lib/boring_services.rb', line 43 def redis_hosts locator.hosts_by_label('redis') end |
.redis_port ⇒ Object
Get Redis port
53 54 55 |
# File 'lib/boring_services.rb', line 53 def redis_port locator.port_for('redis') || 6379 end |
.redis_url(label: nil, password: nil, db: 0) ⇒ Object
Build Redis URL for a label
58 59 60 |
# File 'lib/boring_services.rb', line 58 def redis_url(label: nil, password: nil, db: 0) locator.redis_url(label: label, password: password, db: db) end |
.reset_locator! ⇒ Object
Reset cached locator (useful for testing or config reload)
36 37 38 |
# File 'lib/boring_services.rb', line 36 def reset_locator! @locator = nil end |
.root ⇒ Object
20 21 22 |
# File 'lib/boring_services.rb', line 20 def root File.('..', __dir__) end |
.status ⇒ Object
24 25 26 27 28 |
# File 'lib/boring_services.rb', line 24 def status config = Configuration.load health_checker = HealthChecker.new(config) health_checker.check_all end |