Class: Synapse::Rails::Providers::Base
- Inherits:
-
Object
- Object
- Synapse::Rails::Providers::Base
- Defined in:
- lib/synapse/rails/providers/base.rb
Class Attribute Summary collapse
- .base_path ⇒ Object
-
.service ⇒ Object
Returns the value of attribute service.
-
.tester ⇒ Object
Returns the value of attribute tester.
Instance Attribute Summary collapse
-
#check ⇒ Object
Returns the value of attribute check.
-
#function ⇒ Object
Returns the value of attribute function.
Class Method Summary collapse
Instance Method Summary collapse
- #config(params = {}) ⇒ Object
- #default_servers ⇒ Object
- #discovery ⇒ Object
- #haproxy ⇒ Object
- #host ⇒ Object
- #hosts ⇒ Object
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
- #path ⇒ Object
- #service ⇒ Object
- #service_name ⇒ Object
- #synapse ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 |
# File 'lib/synapse/rails/providers/base.rb', line 18 def initialize params={} @function = "common" @default_servers = [] config params end |
Class Attribute Details
.base_path ⇒ Object
8 9 10 |
# File 'lib/synapse/rails/providers/base.rb', line 8 def base_path @base_path ||= "/nerve" end |
.service ⇒ Object
Returns the value of attribute service.
6 7 8 |
# File 'lib/synapse/rails/providers/base.rb', line 6 def service @service end |
.tester ⇒ Object
Returns the value of attribute tester.
6 7 8 |
# File 'lib/synapse/rails/providers/base.rb', line 6 def tester @tester end |
Instance Attribute Details
#check ⇒ Object
Returns the value of attribute check.
17 18 19 |
# File 'lib/synapse/rails/providers/base.rb', line 17 def check @check end |
#function ⇒ Object
Returns the value of attribute function.
17 18 19 |
# File 'lib/synapse/rails/providers/base.rb', line 17 def function @function end |
Class Method Details
Instance Method Details
#config(params = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/synapse/rails/providers/base.rb', line 50 def config params={} params.each do |k,v| self.send(:"#{k}=",v) rescue nil end end |
#default_servers ⇒ Object
40 41 42 |
# File 'lib/synapse/rails/providers/base.rb', line 40 def default_servers @default_servers end |
#discovery ⇒ Object
29 30 31 32 33 |
# File 'lib/synapse/rails/providers/base.rb', line 29 def discovery %i{method path hosts}.collect do |element| [element,self.send(element)] end.to_h.with_indifferent_access end |
#haproxy ⇒ Object
34 35 36 37 38 39 |
# File 'lib/synapse/rails/providers/base.rb', line 34 def haproxy unless ::Synapse::Rails.started? @haproxy = ::Synapse::Rails::ProviderProxy.new(check:@check).haproxy end @haproxy end |
#host ⇒ Object
61 62 63 |
# File 'lib/synapse/rails/providers/base.rb', line 61 def host "127.0.0.1" end |
#hosts ⇒ Object
26 27 28 |
# File 'lib/synapse/rails/providers/base.rb', line 26 def hosts @hosts ||= self.class.hosts end |
#path ⇒ Object
23 24 25 |
# File 'lib/synapse/rails/providers/base.rb', line 23 def path [base_path,::Synapse::Tenancy.customer,service,function,"services"].join("/") end |
#service ⇒ Object
58 59 60 |
# File 'lib/synapse/rails/providers/base.rb', line 58 def service self.class.service end |
#service_name ⇒ Object
55 56 57 |
# File 'lib/synapse/rails/providers/base.rb', line 55 def service_name [service,function].join("_") end |
#synapse ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/synapse/rails/providers/base.rb', line 43 def synapse { default_servers:default_servers, discovery: discovery, haproxy: haproxy, }.with_indifferent_access end |