clockwork_database_events 0.2.1 → 0.2.3

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: 16d18696ec527a0d6a30f93540b077bc930a08f1
4
- data.tar.gz: fa62c95f87f78dbf95fa83525dd9e1d78243db7e
3
+ metadata.gz: 312cd53eee9c30a272a16d9371737249a40a22f3
4
+ data.tar.gz: ae308ede070b5302c88d3f862d0115d7b6385953
5
5
  SHA512:
6
- metadata.gz: 69d4caa4c455e0fa17fa07a4acf4c507ba7c7da2c88718b0913ce9d492303ffd7b714fc6e183b7462aa38b237f4d47a7492e9d8d12ff0623b71aa17fdd9acdb9
7
- data.tar.gz: cbd21904b3c4a2ba20ffbbd13d72fde3ecde4fb38a0965543c875feb8a2317f072314989eff9bf36bc2df4b35c4fcd0c34be6de61615a1855c149e7b57bf9932
6
+ metadata.gz: 47035005eb34735114d128b472bfbd4c6ff99d4d0dc3396fa8d0a19868ba9952cd10410eb8b9b1cc2f5c858293c697eba272af5823f3d8e8db62e267d27687b2
7
+ data.tar.gz: b16919f9a9908ed19ce36dc772f6979b08dfc031c3f0b7a16508ad81794f986fdf60f4a4370e299d5c6912316d3ecda8917e348f50ad625f9d0fc1916ee093f9
@@ -1,3 +1,6 @@
1
+ require 'sequel'
2
+ require 'faraday'
3
+ require 'diplomat'
1
4
  require 'clockwork_database_events/version'
2
5
 
3
6
  # clockwork database events
@@ -11,4 +14,36 @@ module ClockworkDatabaseEvents
11
14
  end
12
15
 
13
16
  module_function :migrate
17
+
18
+ def connect(db_url=url)
19
+ Sequel.connect(db_url)
20
+ end
21
+
22
+ module_function :connect
23
+
24
+ def url
25
+ if ENV['SKALERA_DB_URL']
26
+ ENV['SKALERA_DB_URL']
27
+ elsif ENV['JENKINS_HOME']
28
+ 'sqlite:/' # for running tests in jenkins
29
+ else
30
+ # TODO: user, password & db should be retrieved from consul
31
+ "postgres://skalera:skalera@#{host}/events"
32
+ end
33
+ end
34
+
35
+ module_function :url
36
+
37
+ def host
38
+ consul = ENV['CONSUL'] || 'consul'
39
+ Diplomat.configuration.url = "http://#{consul}:8500"
40
+
41
+ postgres_config = Diplomat::Service.get('postgres')
42
+ postgres_config.Address
43
+ rescue Faraday::ConnectionFailed => e
44
+ puts "unable to lookup '#{consul}': #{e.message}"
45
+ raise e
46
+ end
47
+
48
+ module_function :host
14
49
  end
@@ -1,4 +1,4 @@
1
1
  # version
2
2
  module ClockworkDatabaseEvents
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clockwork_database_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Englund