philae 0.2.3 → 0.2.4

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: ac79feca959e026f19b70a6abbaee1f6342f34e5
4
- data.tar.gz: c709ee164de58ddc3dc1750af4fb62980c9c97f3
3
+ metadata.gz: 52665bd2cc49aad1dfdc3c7c53661e886ecb2960
4
+ data.tar.gz: c995b59612c527541139225798d1e58d654e15e6
5
5
  SHA512:
6
- metadata.gz: 433c9177c00e5753f815aae3d57693463e28a4d9371f51c252c28e49d3f49cff396ca903aab0877569b0de43d82cbbc59e54f2329394816558ed2674e362e00d
7
- data.tar.gz: f782fc2344e859607d1d08ed4ec01c31c9c7d463b075e0191d6099e7b2030cde681a9d2b720a11302ea73e3383db687b2af8d9bbfe2e64c059927b4354b7ae86
6
+ metadata.gz: 35be4d2d3316b3992a852b4b51192e7ed153919fffc30ca489cc81e1be0912d7b46cf8784b90636df6100565a0cd5bf2c38b56e22500dc95caef3ffe802571fb
7
+ data.tar.gz: 7bf212df4572ce144eb9cb2d8b7bf3a0a080539194a2e9c05ad61a0e6b7f0e1788d8c8c329aa692d780dbaaadbceb2951fe5b0ac28aae8796846a4e1779edc63
@@ -0,0 +1,46 @@
1
+ require 'etcd'
2
+
3
+ # Philae::EtcdProbe tries to connect to the given host and port. To perform the check, it executes a
4
+ # simple get on `/`.
5
+ #
6
+ # If you need to connect to etcd using a custom CA cert, you can give it along with the SSL cert and
7
+ # key to the constructor.
8
+ module Philae
9
+ class EtcdProbe
10
+ attr_reader :name
11
+
12
+ # @param [Integer] read_timeout Timeout in second for the HTTP request
13
+ def initialize(name, host, port, read_timeout=1, cacert=nil, ssl_cert=nil, ssl_key=nil)
14
+ if not cacert.nil? and (ssl_cert.nil? or ssl_key.nil?)
15
+ raise ArgumentError
16
+ end
17
+ @name = name
18
+ @host = host
19
+ @port = port
20
+ @read_timeout = read_timeout
21
+ @cacert = cacert
22
+ @ssl_cert = ssl_cert
23
+ @ssl_key = ssl_key
24
+ end
25
+
26
+ def check
27
+ begin
28
+ opts = {
29
+ host: @host,
30
+ port: @port,
31
+ read_timeout: @read_timeout,
32
+ }
33
+ if not @cacert.nil?
34
+ opts[:cacert] = @cacert
35
+ opts[:ssl_cert] = @ssl_cert
36
+ opts[:ssl_key] = @ssl_key
37
+ end
38
+ client = Etcd.client(opts)
39
+ client.get '/'
40
+ rescue
41
+ return { healthy: false, comment: 'Unable to contact etcd' }
42
+ end
43
+ { healthy: true, comment: '' }
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,7 @@
1
1
  require 'mongo'
2
2
 
3
+ # Philae::MongoProbe tries to connect to the given URI and list the collection names. The URI must
4
+ # be in the form `mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]`
3
5
  module Philae
4
6
  class MongoProbe
5
7
  attr_reader :name
@@ -15,7 +17,7 @@ module Philae
15
17
  db = client.database
16
18
  db.collection_names
17
19
  rescue
18
- return { healthy: false, comment: 'Unable to conctact mongo' }
20
+ return { healthy: false, comment: 'Unable to contact mongo' }
19
21
  end
20
22
  { healthy: true, comment: '' }
21
23
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo@scalingo.com
8
8
  - john@scalingo.com
9
+ - etienne@scalingo.com
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2017-04-24 00:00:00.000000000 Z
13
+ date: 2017-06-14 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: docker-api
@@ -53,6 +54,20 @@ dependencies:
53
54
  - - "~>"
54
55
  - !ruby/object:Gem::Version
55
56
  version: '2.1'
57
+ - !ruby/object:Gem::Dependency
58
+ name: etcd
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '0.3'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '0.3'
56
71
  description:
57
72
  email: hello@scalingo.com
58
73
  executables: []
@@ -61,6 +76,7 @@ extra_rdoc_files: []
61
76
  files:
62
77
  - lib/philae.rb
63
78
  - lib/philae/docker_probe.rb
79
+ - lib/philae/etcd_probe.rb
64
80
  - lib/philae/http_probe.rb
65
81
  - lib/philae/mongo_probe.rb
66
82
  - lib/philae/nsq_probe.rb
@@ -90,5 +106,5 @@ rubyforge_project:
90
106
  rubygems_version: 2.5.2
91
107
  signing_key:
92
108
  specification_version: 4
93
- summary: Provide an healthcheck api
109
+ summary: Provide an health check api
94
110
  test_files: []