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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3046a34853d7d292355165b39138cae71ecc619
4
- data.tar.gz: 7e48cd66da2af730f6cb0a9bafe151e5182ada33
3
+ metadata.gz: 90e02e2e17840313b40059cba5b299b12f0613d1
4
+ data.tar.gz: f9930675ef228f59f447e53add00c85c27c50a6f
5
5
  SHA512:
6
- metadata.gz: 73e16af6299354ba6a37078de24251f1171e501bfb614c00b7a3e835a6f1c068a741c39428764f2326db75445a9279be86b6b377f0d58e27fd3d96a6079b4d42
7
- data.tar.gz: d4e9de191164c5623b112a6fcf465be7f7f4d2804a835e072b3572adc826f7f08dff7ed651a541d46e5551a3436acd4a9bf441b9c12728e9ee72030853812d2a
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
- TODO: Write usage instructions here
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
 
@@ -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.info "HAproxy cleanup finish"
102
+ logger.debug "Boutons shut down"
105
103
  end
106
104
  services.inform synapse
107
105
  synapse.services = services
@@ -1,3 +1,3 @@
1
1
  module Boutons
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.8"
3
3
  end
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.7
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-04-30 00:00:00.000000000 Z
11
+ date: 2015-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: synapse