farmstead 0.0.48 → 0.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/farmstead/pipeline/extract.rb +1 -1
- data/lib/farmstead/pipeline/load.rb +9 -26
- data/lib/farmstead/pipeline/manage.rb +10 -16
- data/lib/farmstead/pipeline/transform.rb +9 -23
- data/lib/farmstead/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec037c550284eabc999c7005441c22fb30c76e76
|
4
|
+
data.tar.gz: b1150538511bafdaf0abd042dae20a2659bd5d23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f10b4378ecdb678166eb64a73bd0c11cda1d9339130623b5bd79c39fdeeb508aa1ca4a9fa6e3a2b836d76a5437f3a40c193cf259a2266b897886c762bce4d26a
|
7
|
+
data.tar.gz: 9c0157d4d40f1dec9d98ace549b5b12d147b0d97402df89bdd903a7d4b4ec93d17b5ede53d8bce2e28b8491d08d3e7efd790c274c94f8c244278e82d5628cec0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
farmstead (0.0.
|
4
|
+
farmstead (0.0.49)
|
5
5
|
httparty (~> 0.15.6)
|
6
6
|
mechanize (~> 2.7)
|
7
7
|
mysql2 (~> 0.4.10)
|
@@ -16,7 +16,7 @@ PATH
|
|
16
16
|
GEM
|
17
17
|
remote: https://rubygems.org/
|
18
18
|
specs:
|
19
|
-
backports (3.11.
|
19
|
+
backports (3.11.1)
|
20
20
|
diff-lcs (1.3)
|
21
21
|
domain_name (0.5.20170404)
|
22
22
|
unf (>= 0.0.5, < 1.0.0)
|
@@ -19,7 +19,7 @@ module Farmstead
|
|
19
19
|
obj = JSON.parse(message.value)
|
20
20
|
my_module = Object.const_get "<%= ENV['name'].capitalize %>::#{obj["module"]}"
|
21
21
|
result = my_module::extract
|
22
|
-
Farmstead::DB.insert("test",
|
22
|
+
Farmstead::DB.insert("test",result: result)
|
23
23
|
@producer.produce(result, topic: "Forest")
|
24
24
|
@producer.deliver_messages
|
25
25
|
@consumer.mark_message_as_processed(message)
|
@@ -3,43 +3,26 @@
|
|
3
3
|
# Load data into database
|
4
4
|
#
|
5
5
|
# Runs a Consumer and it will automatically pick up
|
6
|
-
# messages from the
|
7
|
-
#
|
6
|
+
# messages from the Road Topic and load the message into
|
7
|
+
# the database
|
8
8
|
#
|
9
9
|
# Every micro-service inherits the Service class
|
10
10
|
module Farmstead
|
11
11
|
module Load
|
12
|
-
|
13
|
-
class Producer < Farmstead::Service
|
12
|
+
class Service < Farmstead::Service
|
14
13
|
def run
|
15
|
-
|
16
|
-
puts "Do something"
|
17
|
-
sleep 300
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Subscribed to the Field topic
|
23
|
-
# Works on message
|
24
|
-
class Consumer < Farmstead::Service
|
25
|
-
def run
|
26
|
-
@consumer.subscribe('Field')
|
14
|
+
@consumer.subscribe("Road")
|
27
15
|
trap('TERM') { @consumer.stop }
|
28
16
|
@consumer.each_message do |message|
|
29
17
|
puts "Received: #{message.value}"
|
30
|
-
|
18
|
+
# Run the load method of the module referenced by the message
|
19
|
+
obj = JSON.parse(message.value)
|
20
|
+
my_module = Object.const_get "<%= ENV['name'].capitalize %>::#{obj["module"]}"
|
21
|
+
result = my_module::load
|
22
|
+
Farmstead::DB.insert("test",result: result)
|
31
23
|
@consumer.mark_message_as_processed(message)
|
32
24
|
end
|
33
25
|
end
|
34
|
-
|
35
|
-
def magic_work(site)
|
36
|
-
hash = JSON.parse(site)
|
37
|
-
hash['scarecrow'] = 'true'
|
38
|
-
json = hash.to_json
|
39
|
-
puts "Writing: #{json}"
|
40
|
-
write_message(json, topic: 'Forest')
|
41
|
-
end
|
42
26
|
end
|
43
27
|
end
|
44
28
|
end
|
45
|
-
|
@@ -4,23 +4,17 @@
|
|
4
4
|
# 1) A new site is added
|
5
5
|
# 2) A scheduled site pull is configured to happen
|
6
6
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# Tinman is running as a Consumer and it will automatically pick up the message
|
10
|
-
# and do it's job and then send a message (as a Producer) to the Field topic
|
11
|
-
#
|
12
|
-
# Scarecrow is running as a Consumer and it will automatically pick up the
|
13
|
-
# message and do it's job and then send a message (as a Producer)
|
14
|
-
# to the Forest topic
|
7
|
+
# Field --> Forest --> Road
|
15
8
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
9
|
+
# It then takes the config from the DB and passed it to the Wood topic
|
10
|
+
#
|
11
|
+
# The Extract class pulls the site config from the Field Topic and then pushes
|
12
|
+
# site data to the Forest topic.
|
13
|
+
#
|
14
|
+
# The Transform class pulls the site data from teh Forest topic and then pushes
|
15
|
+
# to the Road topic.
|
16
|
+
#
|
17
|
+
# The Load class pulls data from the Road topic and loads it into the database.
|
24
18
|
#
|
25
19
|
# Topics are created when Kafka comes up
|
26
20
|
# HINT: See .env
|
@@ -12,36 +12,22 @@
|
|
12
12
|
# Every micro-service inherits the Service class
|
13
13
|
module Farmstead
|
14
14
|
module Transform
|
15
|
-
|
16
|
-
class Producer < Farmstead::Service
|
15
|
+
class Service < Farmstead::Service
|
17
16
|
def run
|
18
|
-
|
19
|
-
puts "Do nothing"
|
20
|
-
sleep 300
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# Subscribed to the Field topic
|
26
|
-
# Works on message
|
27
|
-
class Consumer < Farmstead::Service
|
28
|
-
def run
|
29
|
-
@consumer.subscribe('Forest')
|
17
|
+
@consumer.subscribe("Forest")
|
30
18
|
trap('TERM') { @consumer.stop }
|
31
19
|
@consumer.each_message do |message|
|
32
20
|
puts "Received: #{message.value}"
|
33
|
-
|
21
|
+
# Run the load method of the module referenced by the message
|
22
|
+
obj = JSON.parse(message.value)
|
23
|
+
my_module = Object.const_get "<%= ENV['name'].capitalize %>::#{obj["module"]}"
|
24
|
+
result = my_module::transform
|
25
|
+
Farmstead::DB.insert("test",result: result)
|
26
|
+
@producer.produce(result, topic: "Road")
|
27
|
+
@producer.deliver_messages
|
34
28
|
@consumer.mark_message_as_processed(message)
|
35
29
|
end
|
36
30
|
end
|
37
|
-
|
38
|
-
def magic_work(site)
|
39
|
-
hash = JSON.parse(site)
|
40
|
-
hash['cowardlylion'] = 'true'
|
41
|
-
json = hash.to_json
|
42
|
-
puts "Writing: #{json}"
|
43
|
-
write_message(json, topic: 'Road')
|
44
|
-
end
|
45
31
|
end
|
46
32
|
end
|
47
33
|
end
|
data/lib/farmstead/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farmstead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Jenney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|