jflow 0.3.5 → 0.3.6
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/lib/jflow.rb +1 -0
- data/lib/jflow/cli.rb +16 -1
- data/lib/jflow/configuration.rb +6 -5
- data/lib/jflow/stats.rb +46 -0
- data/lib/jflow/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee227c0d6cfc06d17a93805bd3c108bef4efe51b
|
4
|
+
data.tar.gz: e5e0046572c7b25d71bab9e654bc926433739265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e5a5a9df63c946880805d2c67815638d9806956e3df6a6c5640a2d1f40d79a0cc6021b9dad4a46f366824b81cfb612046b04d9e2b126b21561ea2cf67468804
|
7
|
+
data.tar.gz: 365419b044cc4844505b516d442af18ee4565d34b42f79edb6b7e2c2582eca8ae1c8e735a51c43e9a23fc10f127981169bdad5d9624075a55b36c7c4ae078f60
|
data/lib/jflow.rb
CHANGED
data/lib/jflow/cli.rb
CHANGED
@@ -8,7 +8,7 @@ module JFlow
|
|
8
8
|
"activities_path" => "array"
|
9
9
|
}
|
10
10
|
|
11
|
-
attr_reader :number_of_workers, :domain, :tasklist, :worker_threads, :activities_path
|
11
|
+
attr_reader :number_of_workers, :domain, :tasklist, :worker_threads, :activities_path, :enable_stats
|
12
12
|
|
13
13
|
def initialize(options)
|
14
14
|
validate_options(options)
|
@@ -16,6 +16,7 @@ module JFlow
|
|
16
16
|
@domain = options["domain"]
|
17
17
|
@tasklist = options["tasklist"]
|
18
18
|
@activities_path = options["activities_path"]
|
19
|
+
@enable_stats = options["enable_stats"] || true
|
19
20
|
@worker_threads = []
|
20
21
|
setup
|
21
22
|
end
|
@@ -24,6 +25,7 @@ module JFlow
|
|
24
25
|
number_of_workers.times do
|
25
26
|
worker_threads << worker_thread
|
26
27
|
end
|
28
|
+
worker_threads << stats_thread if enable_stats
|
27
29
|
worker_threads.each(&:join)
|
28
30
|
end
|
29
31
|
|
@@ -58,10 +60,23 @@ module JFlow
|
|
58
60
|
JFlow.configure do |c|
|
59
61
|
c.load_paths = activities_path
|
60
62
|
c.swf_client = Aws::SWF::Client.new
|
63
|
+
c.cloudwatch_client = Aws::CloudWatch::Client.new
|
61
64
|
end
|
62
65
|
JFlow.load_activities
|
63
66
|
end
|
64
67
|
|
68
|
+
def stats_thread
|
69
|
+
JFlow::WorkerThread.new do
|
70
|
+
Thread.current.set_state(:polling)
|
71
|
+
stats = JFlow::Stats.new(@domain, @tasklist)
|
72
|
+
loop do
|
73
|
+
break if Thread.current.marked_for_shutdown?
|
74
|
+
stats.tick
|
75
|
+
sleep 30
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
65
80
|
def kill_thread(thread)
|
66
81
|
Thread.new do
|
67
82
|
sleep 60
|
data/lib/jflow/configuration.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module JFlow
|
2
2
|
class Configuration
|
3
3
|
|
4
|
-
attr_accessor :swf_client, :load_paths, :logger, :activity_map
|
4
|
+
attr_accessor :swf_client, :load_paths, :logger, :activity_map, :cloudwatch_client
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@swf_client
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
7
|
+
@swf_client = nil
|
8
|
+
@cloudwatch_client = nil
|
9
|
+
@load_paths = []
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
@activity_map = JFlow::Activity::Map.new
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/jflow/stats.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module JFlow
|
2
|
+
class Stats
|
3
|
+
|
4
|
+
attr_reader :domain_name, :tasklist
|
5
|
+
|
6
|
+
def initialize(domain_name, tasklist)
|
7
|
+
@domain_name = domain_name
|
8
|
+
@tasklist = tasklist
|
9
|
+
end
|
10
|
+
|
11
|
+
def tick
|
12
|
+
value = backlog_count
|
13
|
+
JFlow.configuration.cloudwatch_client.put_metric_data({
|
14
|
+
namespace: "SWF/Custom",
|
15
|
+
metric_data: [
|
16
|
+
{
|
17
|
+
metric_name: "TasklistBacklog",
|
18
|
+
dimensions: [
|
19
|
+
{
|
20
|
+
name: "Domain",
|
21
|
+
value: domain_name,
|
22
|
+
},{
|
23
|
+
name: "Tasklist",
|
24
|
+
value: tasklist,
|
25
|
+
}
|
26
|
+
],
|
27
|
+
timestamp: Time.now,
|
28
|
+
value: value,
|
29
|
+
unit: "Count"
|
30
|
+
},
|
31
|
+
],
|
32
|
+
})
|
33
|
+
JFlow.configuration.logger.debug "Sending tick stats with value: #{value}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def backlog_count
|
37
|
+
JFlow.configuration.swf_client.count_pending_activity_tasks({
|
38
|
+
domain: domain_name,
|
39
|
+
task_list: {
|
40
|
+
name: tasklist,
|
41
|
+
},
|
42
|
+
}).count
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/jflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christophe Verbinnen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/jflow/cli.rb
|
124
124
|
- lib/jflow/configuration.rb
|
125
125
|
- lib/jflow/domain.rb
|
126
|
+
- lib/jflow/stats.rb
|
126
127
|
- lib/jflow/version.rb
|
127
128
|
- lib/jflow/worker_thread.rb
|
128
129
|
homepage: https://github.com/djpate/jflow
|