doorkeepr 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0bd2f5550e8cf00fe4a3a5f325e4526999cefa0
4
- data.tar.gz: f4dacfc22262e372fa2ad3683ced5e4aaba70fb1
3
+ metadata.gz: c5254314c92311ba0bc90fbde82759f6c685e31a
4
+ data.tar.gz: 97412783a1dae4811e92b08c2b64fc485433d251
5
5
  SHA512:
6
- metadata.gz: 64a0f3f59a8f8efb7b297f6e4bbb152fff68850997a82a8928e3db4fd64b7ad13e3ed3903e74f1db5a8cb41a9ebcec18bde7f20c5bf144581cca67eb9e9d56d2
7
- data.tar.gz: 5a88826c1bced56f66a429e1775623a295e3d4fc1d13c387a356f2309eaa34cbf117d70de9de309214a4ed52a5f6f75c3d5b33fabcbb60e376c524c283d4fea1
6
+ metadata.gz: 608b7dd7fa6c686d29cd85c2c890aedbed67c6245895defaff48c7fbe3b79f22066bd0b78e01ffef941bb283e72cc861906b44e2c2ba82bf1124f9af4faaa70f
7
+ data.tar.gz: fde9ebbd151d3988dd45f6f75052fc9eff73b3fa2400f5960201097a1aabee991671923963a81b369dc4d29ebf6c5c54f7ae56e3867dd062eb9ebb58fd3dc0cb
data/lib/doorkeepr.rb CHANGED
@@ -10,6 +10,9 @@ module Doorkeepr
10
10
  def publish
11
11
  Doorkeepr::Nerve.publish if defined? ::Rails::Server
12
12
  end
13
+ def paths
14
+ @paths ||= []
15
+ end
13
16
  end
14
17
  end
15
18
 
@@ -1,12 +1,16 @@
1
1
  module Doorkeepr
2
2
  class Config < OpenStruct
3
3
  def initialize params={}
4
- params[:host] = ::Rails::Server.new.options[:Host] if defined? ::Rails::Server
5
- params[:host] ||= "localhost"
6
- params[:port] = ::Rails::Server.new.options[:Port] if defined? ::Rails::Server
7
- params[:port] ||= 3000
8
- params[:url] = ::Rails.application.class.parent_name.underscore.gsub(/_/,"-").sub(/$/,".dev")
9
- params[:url] ||= "rails.dev"
4
+ params[:host] = ::Rails::Server.new.options[:Host] if defined? ::Rails::Server
5
+ params[:host] = "localhost" if params[:host] == "0.0.0.0"
6
+ params[:host] ||= "localhost"
7
+ params[:port] = ::Rails::Server.new.options[:Port] if defined? ::Rails::Server
8
+ params[:port] ||= 3000
9
+ params[:url] = ::Rails.application.class.parent_name.underscore.gsub(/_/,"-").sub(/$/,".dev")
10
+ params[:url] ||= "rails.dev"
11
+ params[:customer] ||= `whoami`.strip
12
+ params[:application] ||= params[:url]
13
+ params[:service] ||= "rails"
10
14
  super params
11
15
  end
12
16
  def to_json
@@ -5,49 +5,56 @@ module Doorkeepr
5
5
  class << self
6
6
  def publish
7
7
  puts "Publishing Server with #{Doorkeepr.config.inspect}"
8
- @nerve_instance = ::Nerve::Nerve.new config
8
+ ap config
9
+ @doorkeepr = ::Nerve::Nerve.new config
9
10
  marshal
10
11
  at_exit do
11
- @nerve.kill
12
+ @threads.each{|t|t.kill}
12
13
  end
13
14
  end
14
- def nerve_instance
15
- @nerve_instance
15
+ def doorkeepr
16
+ @doorkeepr
17
+ end
18
+ def nerve
16
19
  end
17
20
  def marshal
18
21
  puts 'Doorkeepr: publish!'
19
- @nerve = Thread.new do
20
- nerve_instance.run
21
- end
22
+ @threads ||= []
23
+ @threads << Thread.new { doorkeepr.run }
24
+ end
25
+ def service uri="/doorkeepr",path:doorkeepr_path
26
+ {
27
+ host: host,
28
+ port: port,
29
+ reporter_type: "zookeeper",
30
+ zk_hosts: zk_hosts,
31
+ zk_path: path,
32
+ check_interval: 5,
33
+ checks: [{timeout:0.2,rise:2,fall:3,type:"http",uri:uri}]
34
+ }
35
+ end
36
+ def additional_paths
37
+ paths = Doorkeepr.paths
38
+ paths ||= []
39
+ paths.collect do |path|
40
+ [
41
+ Digest::MD5.hexdigest(path),
42
+ service(uri,path:path)
43
+ ]
44
+ end.to_h
22
45
  end
23
46
  def config
24
47
  {
25
48
  instance_id: instance_id,
26
49
  services: {
27
- application => {
28
- host: host,
29
- port: port,
30
- reporter_type: "zookeeper",
31
- zk_hosts: zk_hosts,
32
- zk_path: doorkeepr_path,
33
- check_interval: 5,
34
- checks: [{timeout:0.2,rise:2,fall:3,type:"http",uri:"/doorkeepr"}]
35
- },
36
- "uplink" => {
37
- host: host,
38
- port: port,
39
- reporter_type: "zookeeper",
40
- zk_hosts: zk_hosts,
41
- zk_path: uplink_path,
42
- check_interval: 5,
43
- checks: [{timeout:0.2,rise:2,fall:3,type:"http",uri:uri}]
44
- }
45
- }
50
+ application => service,
51
+ "uplink" => service(uri,path:uplink_path)
52
+ }.merge(additional_paths)
46
53
  }.with_indifferent_access
47
54
  end
48
55
  def uplink_path
49
56
  @uplink_path = Doorkeepr.config.uplink
50
- @uplink_path ||= "/nerve/global/#{Doorkeepr.config.url}/rails/services"
57
+ @uplink_path ||= "/nerve/#{Doorkeepr.config.customer}/#{Doorkeepr.config.application}/#{Doorkeepr.config.service}/services"
51
58
  end
52
59
  def doorkeepr_path
53
60
  @doorkeepr_path = Doorkeepr.config.path
@@ -1,3 +1,3 @@
1
1
  module Doorkeepr
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeepr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Kaufmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2015-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails