clockwork_database_events 0.2.5 → 0.2.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f44c4fc8fe2401f87d818212eb6c14b19285747
|
4
|
+
data.tar.gz: 371c4cc5b31e9a8da638643e410471edd119d0ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69885939ff7abcfb1f7502e1fce39835004d1f9562ab613b876ef88315450e970f5e9d6e5ba0ebbc891d82d483a6293188cb44b38fa935c354eb90fbbfc47c2
|
7
|
+
data.tar.gz: 32346a0c9e27ce6e6de6e386601532897a4b49580722ef0a8ee51646b8d6a246bc000cdc1bde13555bfe44ab81617de9195562a78cf3424e1ce058cae4a64722
|
@@ -14,36 +14,4 @@ module ClockworkDatabaseEvents
|
|
14
14
|
end
|
15
15
|
|
16
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
|
49
17
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'logger'
|
1
2
|
require 'active_support/time'
|
2
3
|
|
3
4
|
Sequel::Model.plugin :timestamps, update_on_create: true
|
@@ -8,10 +9,11 @@ require 'clockwork_database_events/models/frequency_period'
|
|
8
9
|
# clockwork database events
|
9
10
|
module ClockworkDatabaseEvents
|
10
11
|
def seed
|
11
|
-
|
12
|
+
logger = Logger.new(ENV['LOGGER'] || STDOUT)
|
13
|
+
logger.debug('seeding frequency table')
|
12
14
|
%w(second minute hour day week month).each do |period|
|
13
15
|
FrequencyPeriod.find_or_create(name: period) do
|
14
|
-
|
16
|
+
logger.info("created #{period}")
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|