doorkeepr 0.0.4 → 0.0.5
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 +4 -4
- data/lib/doorkeepr.rb +3 -0
- data/lib/doorkeepr/config.rb +10 -6
- data/lib/doorkeepr/nerve.rb +34 -27
- data/lib/doorkeepr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5254314c92311ba0bc90fbde82759f6c685e31a
|
4
|
+
data.tar.gz: 97412783a1dae4811e92b08c2b64fc485433d251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 608b7dd7fa6c686d29cd85c2c890aedbed67c6245895defaff48c7fbe3b79f22066bd0b78e01ffef941bb283e72cc861906b44e2c2ba82bf1124f9af4faaa70f
|
7
|
+
data.tar.gz: fde9ebbd151d3988dd45f6f75052fc9eff73b3fa2400f5960201097a1aabee991671923963a81b369dc4d29ebf6c5c54f7ae56e3867dd062eb9ebb58fd3dc0cb
|
data/lib/doorkeepr.rb
CHANGED
data/lib/doorkeepr/config.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
module Doorkeepr
|
2
2
|
class Config < OpenStruct
|
3
3
|
def initialize params={}
|
4
|
-
params[:host]
|
5
|
-
params[:host]
|
6
|
-
params[:
|
7
|
-
params[:port]
|
8
|
-
params[:
|
9
|
-
params[:url]
|
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
|
data/lib/doorkeepr/nerve.rb
CHANGED
@@ -5,49 +5,56 @@ module Doorkeepr
|
|
5
5
|
class << self
|
6
6
|
def publish
|
7
7
|
puts "Publishing Server with #{Doorkeepr.config.inspect}"
|
8
|
-
|
8
|
+
ap config
|
9
|
+
@doorkeepr = ::Nerve::Nerve.new config
|
9
10
|
marshal
|
10
11
|
at_exit do
|
11
|
-
@
|
12
|
+
@threads.each{|t|t.kill}
|
12
13
|
end
|
13
14
|
end
|
14
|
-
def
|
15
|
-
@
|
15
|
+
def doorkeepr
|
16
|
+
@doorkeepr
|
17
|
+
end
|
18
|
+
def nerve
|
16
19
|
end
|
17
20
|
def marshal
|
18
21
|
puts 'Doorkeepr: publish!'
|
19
|
-
@
|
20
|
-
|
21
|
-
|
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
|
-
|
29
|
-
|
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
|
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
|
data/lib/doorkeepr/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|