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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec037c550284eabc999c7005441c22fb30c76e76
4
- data.tar.gz: b1150538511bafdaf0abd042dae20a2659bd5d23
3
+ metadata.gz: 5712d13aae031ac927525c97979c557f931262ce
4
+ data.tar.gz: 18b9fa530fb0b0489e422f97b10dbe669ef8a0ef
5
5
  SHA512:
6
- metadata.gz: f10b4378ecdb678166eb64a73bd0c11cda1d9339130623b5bd79c39fdeeb508aa1ca4a9fa6e3a2b836d76a5437f3a40c193cf259a2266b897886c762bce4d26a
7
- data.tar.gz: 9c0157d4d40f1dec9d98ace549b5b12d147b0d97402df89bdd903a7d4b4ec93d17b5ede53d8bce2e28b8491d08d3e7efd790c274c94f8c244278e82d5628cec0
6
+ metadata.gz: 2f81c5592410eb571c2ff326880ab4b65ba3f93c39977f12ce3b355c06fbb0e1aafe63c1da1f9a756a1b52e8a005a80492cbbb99e48074e0d0f963a0c71cf338
7
+ data.tar.gz: aa91a947497c79ccf7879ee30ff514900953c1fcaf1d7b8ad34382d40632b9f5f7fd92433f5081bb579c3177808a8b359dd4938bc9f8f2e9604be5f86f5039d7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- farmstead (0.0.49)
4
+ farmstead (0.0.50)
5
5
  httparty (~> 0.15.6)
6
6
  mechanize (~> 2.7)
7
7
  mysql2 (~> 0.4.10)
data/lib/farmstead/db.rb CHANGED
@@ -22,6 +22,7 @@ module Farmstead
22
22
  primary_key(:id)
23
23
  String(:name)
24
24
  String(:type)
25
+ String(:config)
25
26
  String(:module)
26
27
  end
27
28
  @@DB.create_table :test do
@@ -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 Wood topic
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 Producer < Farmstead::Service
24
+ class Service < Farmstead::Service
25
25
  def run
26
- loop do
27
- puts 'Checking sites'
28
- check_sites
29
- puts 'Checking tasks'
30
- # regular_tasks
31
- sleep 3
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 sites to be processed
35
+ # Checks for any new sources to be processed
36
36
  # Adds them to the message queue
37
- def check_sites
38
- sites = @mysql.query("SELECT * FROM sites WHERE pickedup = 'false'")
39
- return false if sites.count.zero?
40
- sites.each do |site|
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:producer]
5
- command=/usr/local/bin/ruby /service/project.rb %(ENV_SERVICE)s Producer
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]
@@ -1,3 +1,3 @@
1
1
  module Farmstead
2
- VERSION = "0.0.49"
2
+ VERSION = "0.0.50"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farmstead
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.49
4
+ version: 0.0.50
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Jenney