boutons 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -1
- data/lib/boutons.rb +13 -15
- data/lib/boutons/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: 90e02e2e17840313b40059cba5b299b12f0613d1
|
4
|
+
data.tar.gz: f9930675ef228f59f447e53add00c85c27c50a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09d92c57d785ed7d3d3febab98a29a6e27e14fe1de5de9dc7d7660ed6b64667e7666aa4fc6401f64806413ae6799f8fbd8f7baefe631462d07f634fd3c96a74b
|
7
|
+
data.tar.gz: 460ecbda7c336496f2b3c329a132c9d176264152ba74335e6362676e974738e790a3dec997ac13c4c280311e99733f6d5c6c183300b28b6832759e251bc92734
|
data/README.md
CHANGED
@@ -22,7 +22,49 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Add `boutons.tml` to your Project (or config subfolder).
|
26
|
+
|
27
|
+
It has the following format:
|
28
|
+
|
29
|
+
[registry.registry_name]
|
30
|
+
"key" = "value"
|
31
|
+
[services]
|
32
|
+
"name" = [ "registry_name://path" ]
|
33
|
+
|
34
|
+
The registry section is optional. Boutons will read this file on demand and checks if a service is listed there. The service-uri will be parsed and Boutons instruct Synapse (AirBnb) to link to this
|
35
|
+
service. Portnumber is choosen randomly at high-port-range (1024+).
|
36
|
+
|
37
|
+
The local address can be found with Boutons.name.to_s (or .s).
|
38
|
+
|
39
|
+
## Example
|
40
|
+
|
41
|
+
boutons.tml
|
42
|
+
[registry.zookeeper]
|
43
|
+
"hosts" = ["localhost:2181"]
|
44
|
+
[services]
|
45
|
+
"postgresql" = [ "zookeeper:///nerve/postgresql/services"]
|
46
|
+
|
47
|
+
irb
|
48
|
+
require "boutons"
|
49
|
+
puts Boutons.postgresql.s
|
50
|
+
|
51
|
+
## Live connections
|
52
|
+
|
53
|
+
Boutons can also add synapses at runtime.
|
54
|
+
|
55
|
+
Boutons.provide "smtp", "zookeeper://zookeeper.mail.company.com:2181/outbound-relay/smtp"
|
56
|
+
puts Boutons.smtp.to_s("%h:%p")
|
57
|
+
|
58
|
+
## String-Format
|
59
|
+
|
60
|
+
the to_s method prints the local uri as default. You may provide some kind of format-string to your needs. The following placeholders will be replaces by it's value:
|
61
|
+
|
62
|
+
%P = Procotol (tcp or http)
|
63
|
+
%h = Hostname
|
64
|
+
%i = IP-Address
|
65
|
+
%p = Portnumber
|
66
|
+
|
67
|
+
Boutons.postgresql.s("%i:%p") => "127.0.0.1:23412"
|
26
68
|
|
27
69
|
## Development
|
28
70
|
|
data/lib/boutons.rb
CHANGED
@@ -22,6 +22,18 @@ module Boutons
|
|
22
22
|
update
|
23
23
|
synapse.check
|
24
24
|
end
|
25
|
+
def provide service, service_uri
|
26
|
+
uri = Boutons::URI.new service_uri
|
27
|
+
params = {}
|
28
|
+
params[:application] = uri.host
|
29
|
+
params[:mode] = uri.mode
|
30
|
+
params[:uri] = uri.check_uri
|
31
|
+
params[:method] = uri.registry.method
|
32
|
+
params[:path] = uri.registry.zk_path
|
33
|
+
params[:hosts] = uri.registry.zk_hosts
|
34
|
+
params[:name] = service.to_sym
|
35
|
+
add Synapse::Easy::Service.new params
|
36
|
+
end
|
25
37
|
def remove name
|
26
38
|
services[mapping[name]] = nil
|
27
39
|
start
|
@@ -58,18 +70,6 @@ module Boutons
|
|
58
70
|
def available
|
59
71
|
Boutons::Config.services.keys.map{|k|k.to_s} rescue []
|
60
72
|
end
|
61
|
-
def provide service, service_uri
|
62
|
-
uri = Boutons::URI.new service_uri
|
63
|
-
params = {}
|
64
|
-
params[:application] = uri.host
|
65
|
-
params[:mode] = uri.mode
|
66
|
-
params[:uri] = uri.check_uri
|
67
|
-
params[:method] = uri.registry.method
|
68
|
-
params[:path] = uri.registry.zk_path
|
69
|
-
params[:hosts] = uri.registry.zk_hosts
|
70
|
-
params[:name] = service.to_sym
|
71
|
-
add Synapse::Easy::Service.new params
|
72
|
-
end
|
73
73
|
private
|
74
74
|
def mapping
|
75
75
|
@@mapping ||= {}
|
@@ -91,17 +91,15 @@ module Boutons
|
|
91
91
|
services.map{|n,s|s.active=true}
|
92
92
|
haproxy.inform synapse
|
93
93
|
at_exit do
|
94
|
-
logger.info "HAproxy cleanup begin"
|
95
94
|
pf = haproxy.pid_file_path
|
96
95
|
cf = haproxy.config_file_path
|
97
96
|
sf = haproxy.socket_file_path
|
98
97
|
pids = File.read(pf).strip
|
99
|
-
logger.info "HAproxy stop: `kill -9 #{pids}`"
|
100
98
|
`kill -9 #{pids}`
|
101
99
|
File.unlink(pf)
|
102
100
|
File.unlink(sf)
|
103
101
|
File.unlink(cf)
|
104
|
-
logger.
|
102
|
+
logger.debug "Boutons shut down"
|
105
103
|
end
|
106
104
|
services.inform synapse
|
107
105
|
synapse.services = services
|
data/lib/boutons/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boutons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Kaufmann
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: synapse
|