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 +4 -4
- data/lib/clockwork_database_events.rb +35 -0
- data/lib/clockwork_database_events/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 312cd53eee9c30a272a16d9371737249a40a22f3
|
4
|
+
data.tar.gz: ae308ede070b5302c88d3f862d0115d7b6385953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|