boutons 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6323d849f1adc7e1abb6cf0031cb892afc38396
4
- data.tar.gz: e70c25a3738a20e41bd8adbdf23491d0fba436d3
3
+ metadata.gz: 4eedf75f5b88e6bc0015378dd9cccd4e32123183
4
+ data.tar.gz: 576fb18f8c227b183c8c104c6aca06a97b7ca8b1
5
5
  SHA512:
6
- metadata.gz: fc3298b2be2ed421a3b1f65a0dcc8bfc0d49869b0d020df69d20be01b14d1405024006afa7b6f175cac6aabc69a3cdd945eb1ad1995c57f61a340d11de26c127
7
- data.tar.gz: f1f0a6e00e850080110b157082fd57e99995059b2492937eaa83d0cc899083f5c837b670750fbf5655970429bbd0e58aeee43190668a2de268202cb70b341a4b
6
+ metadata.gz: 4a2ff48868a766cd4ee4d7725b9f118f37badd575a3eb60294452e07fe792d5b0e63a4ef18fb6391ea6aba0de92304332bb44699ecd127c783c4f0ebbe6531da
7
+ data.tar.gz: 400f48bfd41954399837c022f5ed11c8e59c5c12a03f16f33e102662c89e4c15fcd617186e858f70da05c0a6f79df1984e1ceff474b168ad679bdaf52a6d9013
@@ -104,18 +104,30 @@ module Boutons
104
104
  def normalize name
105
105
  name.to_s.gsub(/\./,"_").to_sym
106
106
  end
107
- def method_missing method, *args, &block
107
+ def service_from_config name
108
+ return if @@mapping[name]
109
+ return unless Boutons::Config.services.zookeeper.keys.include? name
110
+ params = Boutons::Config.discovery.zookeeper rescue {}
111
+ params[:application] = name
112
+ params[:path] = Boutons::Config.services.zookeeper.send(name)
113
+ Boutons.add Synapse::Easy::Service.new params
114
+ end
115
+ def resolv_service method, *args, &block
116
+ service_from_config method
108
117
  name = @@mapping[method]
109
118
  unless name
110
119
  return @@services.send(method, *args, &block) if @@services.respond_to? method
111
- raise SynapseNotFound.new("The Synapse #{method} cannot be resolved") unless name
120
+ raise SynapseNotFound.new("The Synapse #{method} is unavailable. Add service #{method} first.") unless name
112
121
  end
113
122
  synapse = @@services[name]
114
- raise SynapseNotFound.new("The Synapse #{method} cannot be resolved") unless synapse
123
+ unless synapse
124
+ raise SynapseNotFound.new("The Synapse #{method} is unavailable. Add service #{method} first.")
125
+ end
115
126
  return synapse if args.empty?
116
127
  synapse.send(args[0],*args,&block)
117
128
  end
129
+ def method_missing method, *args, &block
130
+ resolv_service method, *args, &block
131
+ end
118
132
  end
119
- end
120
-
121
- require "boutons/early_start"
133
+ end
@@ -9,12 +9,17 @@ module Boutons
9
9
  return file if File.exists? file
10
10
  end
11
11
  end
12
+ def use
13
+ services.zookeeper.each do |service,path|
14
+ Boutons.add Synapse::Easy::Service.new application: service, path: path, hosts: (discovery.zookeeper.hosts rescue nil)
15
+ end rescue nil
16
+ end
12
17
  private
13
- def config
14
- @config ||= self.new TOML.load_file(file,symbolize_keys:true)
18
+ def config params={}
19
+ @config ||= self.new TOML.load_file(file,symbolize_keys:true).deep_merge(params)
15
20
  end
16
21
  def method_missing method, *args, &block
17
- config.send method, *args, &block
22
+ config.send(method, *args, &block) rescue nil
18
23
  end
19
24
  end
20
25
  def keys
@@ -1,3 +1,3 @@
1
1
  module Boutons
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boutons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Kaufmann
@@ -154,7 +154,6 @@ files:
154
154
  - boutons.gemspec
155
155
  - lib/boutons.rb
156
156
  - lib/boutons/config.rb
157
- - lib/boutons/early_start.rb
158
157
  - lib/boutons/synapse.rb
159
158
  - lib/boutons/version.rb
160
159
  homepage: https://synapse.stei.gr/boutons
@@ -1,5 +0,0 @@
1
- require "synapse/easy/service"
2
-
3
- Boutons::Config.services.zookeeper.each do |service,path|
4
- Boutons.add Synapse::Easy::Service.new application: service, path: path, hosts: (Boutons::Config.discovery.zookeeper.hosts rescue nil)
5
- end rescue nil