farmstead 0.0.49 → 0.0.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/farmstead/db.rb +1 -0
- data/lib/farmstead/pipeline/manage.rb +13 -43
- data/lib/farmstead/scaffold/supervisord.conf.erb +2 -6
- data/lib/farmstead/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: 5712d13aae031ac927525c97979c557f931262ce
|
4
|
+
data.tar.gz: 18b9fa530fb0b0489e422f97b10dbe669ef8a0ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f81c5592410eb571c2ff326880ab4b65ba3f93c39977f12ce3b355c06fbb0e1aafe63c1da1f9a756a1b52e8a005a80492cbbb99e48074e0d0f963a0c71cf338
|
7
|
+
data.tar.gz: aa91a947497c79ccf7879ee30ff514900953c1fcaf1d7b8ad34382d40632b9f5f7fd92433f5081bb579c3177808a8b359dd4938bc9f8f2e9604be5f86f5039d7
|
data/Gemfile.lock
CHANGED
data/lib/farmstead/db.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#
|
7
7
|
# Field --> Forest --> Road
|
8
8
|
#
|
9
|
-
# It then takes the config from the DB and passed it to the
|
9
|
+
# It then takes the config from the DB and passed it to the Field topic
|
10
10
|
#
|
11
11
|
# The Extract class pulls the site config from the Field Topic and then pushes
|
12
12
|
# site data to the Forest topic.
|
@@ -21,53 +21,23 @@
|
|
21
21
|
# Every micro-service inherits the Service class
|
22
22
|
module Farmstead
|
23
23
|
module Manage
|
24
|
-
class
|
24
|
+
class Service < Farmstead::Service
|
25
25
|
def run
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
puts
|
30
|
-
|
31
|
-
|
26
|
+
# Cycle thru sources, pull config and pass to Kafka
|
27
|
+
@@DB[:sources].each do |source|
|
28
|
+
result = source["config"]
|
29
|
+
puts result
|
30
|
+
@producer.produce(result, topic: "Field")
|
31
|
+
@producer.deliver_messages
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
# Checks for any new
|
35
|
+
# Checks for any new sources to be processed
|
36
36
|
# Adds them to the message queue
|
37
|
-
def
|
38
|
-
|
39
|
-
return false if
|
40
|
-
|
41
|
-
json = site.to_json
|
42
|
-
siteid = get_from_json(json, 'id')
|
43
|
-
# import_site(json, siteid)
|
44
|
-
write_message(json, topic: 'Wood')
|
45
|
-
mark_pickedup(siteid)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# Subscribed to the Road topic
|
51
|
-
# Imports Hash into MySQL Database for each message
|
52
|
-
class Consumer < Farmstead::Service
|
53
|
-
def run
|
54
|
-
@consumer.subscribe('Road')
|
55
|
-
trap('TERM') { @consumer.stop }
|
56
|
-
@consumer.each_message do |message|
|
57
|
-
puts "Received: #{message.value}"
|
58
|
-
hash = JSON.parse(message.value)
|
59
|
-
import_site(hash, hash[:id])
|
60
|
-
mark_processed(hash[:id])
|
61
|
-
@consumer.mark_message_as_processed(message)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Checks for any new sites to be processed
|
66
|
-
# Adds them to the message queue
|
67
|
-
def check_sites
|
68
|
-
sites = @mysql.query("SELECT * FROM sites WHERE pickedup = 'false'")
|
69
|
-
return false if sites.count.zero?
|
70
|
-
sites.each do |site|
|
37
|
+
def check_sources
|
38
|
+
sources = @mysql.query("SELECT * FROM sources WHERE pickedup = 'false'")
|
39
|
+
return false if sources.count.zero?
|
40
|
+
sources.each do |site|
|
71
41
|
json = site.to_json
|
72
42
|
siteid = get_from_json(json, 'id')
|
73
43
|
# import_site(json, siteid)
|
@@ -1,12 +1,8 @@
|
|
1
1
|
[supervisord]
|
2
2
|
nodaemon=true
|
3
3
|
|
4
|
-
[program:
|
5
|
-
command=/usr/local/bin/ruby /service/project.rb %(ENV_SERVICE)s
|
6
|
-
redirect_stderr=true
|
7
|
-
|
8
|
-
[program:consumer]
|
9
|
-
command=/usr/local/bin/ruby /service/project.rb %(ENV_SERVICE)s Consumer
|
4
|
+
[program:service]
|
5
|
+
command=/usr/local/bin/ruby /service/project.rb %(ENV_SERVICE)s Service
|
10
6
|
redirect_stderr=true
|
11
7
|
|
12
8
|
[program:api]
|
data/lib/farmstead/version.rb
CHANGED