funktor 0.2.10 → 0.2.11
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/funktor.rb +1 -0
- data/lib/funktor/active_job_handler.rb +7 -0
- data/lib/funktor/counter.rb +42 -0
- data/lib/funktor/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99102148cae3682c1c870882cd44b9651869e3d1ec3adb7e3b4145ef7a6becf5
|
4
|
+
data.tar.gz: c6adb462dbe095673a72e81570d293a59a7f75d18376178684cabe5c81342f3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501e7dd2f92ff36d492da512861bf4dd6ab56f07a4fcbc6c362fa5249a52f0e2694b835d6eda1b454304046be2315c8a9a253c92a25e8548605a7dc4829008ac
|
7
|
+
data.tar.gz: fa98731784d2b0007b9bf831b2536f9ec93bbb5a8870e7f5b9e8810b414002d1f760000d18fa581b7e6f8016f48e9dbca1d905bf1d2821dbfaf85cdec80158dc
|
data/Gemfile.lock
CHANGED
data/lib/funktor.rb
CHANGED
@@ -3,6 +3,11 @@ require 'aws-sdk-sqs'
|
|
3
3
|
module Funktor
|
4
4
|
class ActiveJobHandler
|
5
5
|
|
6
|
+
def initialize
|
7
|
+
@failed_counter = Funktor::Counter.new('failed')
|
8
|
+
@processed_counter = Funktor::Counter.new('processed')
|
9
|
+
end
|
10
|
+
|
6
11
|
def call(event:, context:)
|
7
12
|
event = Funktor::Aws::Sqs::Event.new(event)
|
8
13
|
puts "event.jobs.count = #{event.jobs.count}"
|
@@ -20,10 +25,12 @@ module Funktor
|
|
20
25
|
Funktor.active_job_handler_middleware.invoke(job) do
|
21
26
|
job.execute
|
22
27
|
end
|
28
|
+
@processed_counter.incr(job)
|
23
29
|
# rescue Funktor::Job::InvalidJsonError # TODO Make this work
|
24
30
|
rescue Exception => e
|
25
31
|
puts "Error during processing: #{$!}"
|
26
32
|
puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
|
33
|
+
@failed_counter.incr(job)
|
27
34
|
attempt_retry_or_bail(job)
|
28
35
|
end
|
29
36
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Funktor
|
2
|
+
class Counter
|
3
|
+
attr_accessor :dimension
|
4
|
+
|
5
|
+
def initialize(dimension)
|
6
|
+
@dimension = dimension
|
7
|
+
end
|
8
|
+
|
9
|
+
def incr(job)
|
10
|
+
put_metric_to_stdout(job)
|
11
|
+
end
|
12
|
+
|
13
|
+
def put_metric_to_stdout(job)
|
14
|
+
puts Funktor.dump_json(metric_hash(job))
|
15
|
+
end
|
16
|
+
|
17
|
+
def metric_hash(job)
|
18
|
+
{
|
19
|
+
"_aws": {
|
20
|
+
"Timestamp": Time.now.strftime('%s%3N').to_i,
|
21
|
+
"CloudWatchMetrics": [
|
22
|
+
{
|
23
|
+
"Namespace": ENV['FUNKTOR_APP_NAME'],
|
24
|
+
"Dimensions": [["WorkerClassName"]],
|
25
|
+
"Metrics": [ # CPU, Memory, Duration, etc...
|
26
|
+
{
|
27
|
+
"Name": dimension,
|
28
|
+
"Unit": "Count"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
"WorkerClassName": job.worker_class_name,
|
35
|
+
"#{dimension}": 1
|
36
|
+
#"count": value,
|
37
|
+
#"requestId": "989ffbf8-9ace-4817-a57c-e4dd734019ee"
|
38
|
+
}
|
39
|
+
#data[key] = value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/funktor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: funktor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Green
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/funktor/cli/templates/lambda_event_handlers/work_queue_handler.rb
|
137
137
|
- lib/funktor/cli/templates/package.json
|
138
138
|
- lib/funktor/cli/templates/serverless.yml
|
139
|
+
- lib/funktor/counter.rb
|
139
140
|
- lib/funktor/fake_job_queue.rb
|
140
141
|
- lib/funktor/incoming_job_handler.rb
|
141
142
|
- lib/funktor/job.rb
|