funktor 0.4.7 → 0.6.2
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/.tool-versions +2 -0
- data/Gemfile.lock +31 -12
- data/funktor-testapp/.envrc +1 -0
- data/funktor-testapp/.gitignore +7 -0
- data/funktor-testapp/Gemfile +25 -0
- data/funktor-testapp/Gemfile.lock +51 -0
- data/funktor-testapp/app/services/job_flood.rb +38 -0
- data/funktor-testapp/app/workers/audit_worker.rb +49 -0
- data/funktor-testapp/app/workers/greetings_worker.rb +3 -0
- data/funktor-testapp/app/workers/hello_worker.rb +18 -0
- data/funktor-testapp/app/workers/single_thread_audit_worker.rb +3 -0
- data/funktor-testapp/deploy-dev.sh +5 -0
- data/funktor-testapp/funktor_config/boot.rb +17 -0
- data/funktor-testapp/funktor_config/environment.yml +15 -0
- data/funktor-testapp/funktor_config/function_definitions/default_queue_handler.yml +13 -0
- data/funktor-testapp/funktor_config/function_definitions/incoming_job_handler.yml +13 -0
- data/funktor-testapp/funktor_config/function_definitions/job_activator.yml +7 -0
- data/funktor-testapp/funktor_config/function_definitions/low_concurrency_queue_handler.yml +13 -0
- data/funktor-testapp/funktor_config/function_definitions/random_job_generator.yml +18 -0
- data/funktor-testapp/funktor_config/funktor.yml +114 -0
- data/funktor-testapp/funktor_config/iam_permissions/activity_table.yml +5 -0
- data/funktor-testapp/funktor_config/iam_permissions/default_queue.yml +8 -0
- data/funktor-testapp/funktor_config/iam_permissions/incoming_job_queue.yml +8 -0
- data/funktor-testapp/funktor_config/iam_permissions/jobs_table.yml +5 -0
- data/funktor-testapp/funktor_config/iam_permissions/jobs_table_secondary_index.yml +8 -0
- data/funktor-testapp/funktor_config/iam_permissions/low_concurrency_queue.yml +8 -0
- data/funktor-testapp/funktor_config/iam_permissions/ssm.yml +5 -0
- data/funktor-testapp/funktor_config/package.yml +11 -0
- data/funktor-testapp/funktor_config/resources/activity_table.yml +22 -0
- data/funktor-testapp/funktor_config/resources/cloudwatch_dashboard.yml +809 -0
- data/funktor-testapp/funktor_config/resources/default_queue.yml +22 -0
- data/funktor-testapp/funktor_config/resources/incoming_job_queue.yml +22 -0
- data/funktor-testapp/funktor_config/resources/incoming_job_queue_user.yml +26 -0
- data/funktor-testapp/funktor_config/resources/jobs_table.yml +56 -0
- data/funktor-testapp/funktor_config/resources/low_concurrency_queue.yml +22 -0
- data/funktor-testapp/funktor_config/ruby_layer.yml +11 -0
- data/funktor-testapp/funktor_init.yml +69 -0
- data/funktor-testapp/lambda_event_handlers/default_queue_handler.rb +8 -0
- data/funktor-testapp/lambda_event_handlers/incoming_job_handler.rb +8 -0
- data/funktor-testapp/lambda_event_handlers/job_activator.rb +8 -0
- data/funktor-testapp/lambda_event_handlers/low_concurrency_queue_handler.rb +8 -0
- data/funktor-testapp/lambda_event_handlers/random_job_generator.rb +35 -0
- data/funktor-testapp/package-lock.json +248 -0
- data/funktor-testapp/package.json +8 -0
- data/funktor-testapp/serverless.yml +66 -0
- data/funktor.gemspec +4 -1
- data/lib/active_job/queue_adapters/funktor_adapter.rb +3 -3
- data/lib/funktor/activity_tracker.rb +106 -0
- data/lib/funktor/cli/bootstrap.rb +0 -1
- data/lib/funktor/cli/init.rb +13 -0
- data/lib/funktor/cli/templates/app/workers/hello_worker.rb +1 -1
- data/lib/funktor/cli/templates/funktor_config/environment.yml +4 -0
- data/lib/funktor/cli/templates/funktor_config/function_definitions/incoming_job_handler.yml +3 -1
- data/lib/funktor/cli/templates/funktor_config/function_definitions/job_activator.yml +7 -0
- data/lib/funktor/cli/templates/funktor_config/function_definitions/work_queue_handler.yml +3 -1
- data/lib/funktor/cli/templates/funktor_config/funktor.yml +32 -6
- data/lib/funktor/cli/templates/funktor_config/iam_permissions/activity_table.yml +5 -0
- data/lib/funktor/cli/templates/funktor_config/iam_permissions/jobs_table.yml +5 -0
- data/lib/funktor/cli/templates/funktor_config/iam_permissions/jobs_table_secondary_index.yml +8 -0
- data/lib/funktor/cli/templates/funktor_config/resources/activity_table.yml +22 -0
- data/lib/funktor/cli/templates/funktor_config/resources/cloudwatch_dashboard.yml +13 -12
- data/lib/funktor/cli/templates/funktor_config/resources/incoming_job_queue.yml +2 -2
- data/lib/funktor/cli/templates/funktor_config/resources/jobs_table.yml +56 -0
- data/lib/funktor/cli/templates/funktor_config/resources/work_queue.yml +2 -2
- data/lib/funktor/cli/templates/funktor_init.yml.tt +16 -16
- data/lib/funktor/cli/templates/lambda_event_handlers/job_activator.rb +8 -0
- data/lib/funktor/cli/templates/lambda_event_handlers/work_queue_handler.rb +1 -1
- data/lib/funktor/cli/templates/serverless.yml +3 -2
- data/lib/funktor/counter.rb +4 -1
- data/lib/funktor/incoming_job_handler.rb +54 -18
- data/lib/funktor/job.rb +57 -7
- data/lib/funktor/job_activator.rb +124 -0
- data/lib/funktor/job_pusher.rb +0 -2
- data/lib/funktor/middleware/metrics.rb +8 -3
- data/lib/funktor/shard_utils.rb +6 -0
- data/lib/funktor/testing.rb +50 -47
- data/lib/funktor/version.rb +1 -1
- data/lib/funktor/web/application.rb +139 -0
- data/lib/funktor/web/views/index.erb +3 -0
- data/lib/funktor/web/views/layout.erb +58 -0
- data/lib/funktor/web/views/processing.erb +29 -0
- data/lib/funktor/web/views/queued.erb +29 -0
- data/lib/funktor/web/views/retries.erb +35 -0
- data/lib/funktor/web/views/scheduled.erb +26 -0
- data/lib/funktor/web/views/stats.erb +9 -0
- data/lib/funktor/web/views/table_stats_with_buttons.erb +11 -0
- data/lib/funktor/web.rb +1 -0
- data/lib/funktor/work_queue_handler.rb +101 -0
- data/lib/funktor/worker/funktor_options.rb +3 -1
- data/lib/funktor/worker.rb +8 -18
- data/lib/funktor.rb +52 -20
- metadata +109 -3
- data/lib/funktor/active_job_handler.rb +0 -58
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 99aa84e15abe58236ad036f0ead087630ab418a99f6240ad438e7e1809e097c7
|
|
4
|
+
data.tar.gz: 3ac97ae4967ba9abff96aa5073e8bb29be144443d8dcbebe27437f9fd12ec57a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dce4b51048490c5a2ee4c8bc794cfe3d23e3fc30ed90e1efd2fb2a9bf49f64eff3fa2656c2784a5b712752398e73caa3ee4e4079da185cbd0d80de8edf41285f
|
|
7
|
+
data.tar.gz: 747d3ed016dff5b1e5fc63deb1e332b29ac53602f40d0f4a88711f59883d2571f72f267021a285decf3c887a542800a8dcb0f50da4c4215f980b4cce80324856
|
data/.tool-versions
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
funktor (0.
|
|
4
|
+
funktor (0.6.2)
|
|
5
5
|
activesupport
|
|
6
|
+
aws-sdk-dynamodb (~> 1.62)
|
|
6
7
|
aws-sdk-sqs (~> 1.37)
|
|
7
8
|
thor
|
|
8
9
|
|
|
9
10
|
GEM
|
|
10
11
|
remote: https://rubygems.org/
|
|
11
12
|
specs:
|
|
12
|
-
activejob (6.1.4)
|
|
13
|
-
activesupport (= 6.1.4)
|
|
13
|
+
activejob (6.1.4.1)
|
|
14
|
+
activesupport (= 6.1.4.1)
|
|
14
15
|
globalid (>= 0.3.6)
|
|
15
|
-
activesupport (6.1.4)
|
|
16
|
+
activesupport (6.1.4.1)
|
|
16
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
17
18
|
i18n (>= 1.6, < 2)
|
|
18
19
|
minitest (>= 5.1)
|
|
19
20
|
tzinfo (~> 2.0)
|
|
20
21
|
zeitwerk (~> 2.3)
|
|
21
|
-
addressable (2.
|
|
22
|
+
addressable (2.8.0)
|
|
22
23
|
public_suffix (>= 2.0.2, < 5.0)
|
|
23
24
|
aws-eventstream (1.1.1)
|
|
24
|
-
aws-partitions (1.
|
|
25
|
-
aws-sdk-core (3.119.
|
|
25
|
+
aws-partitions (1.491.0)
|
|
26
|
+
aws-sdk-core (3.119.1)
|
|
26
27
|
aws-eventstream (~> 1, >= 1.0.2)
|
|
27
28
|
aws-partitions (~> 1, >= 1.239.0)
|
|
28
29
|
aws-sigv4 (~> 1.1)
|
|
29
30
|
jmespath (~> 1.0)
|
|
31
|
+
aws-sdk-dynamodb (1.62.0)
|
|
32
|
+
aws-sdk-core (~> 3, >= 3.119.0)
|
|
33
|
+
aws-sigv4 (~> 1.1)
|
|
30
34
|
aws-sdk-sqs (1.42.0)
|
|
31
35
|
aws-sdk-core (~> 3, >= 3.119.0)
|
|
32
36
|
aws-sigv4 (~> 1.1)
|
|
@@ -38,8 +42,8 @@ GEM
|
|
|
38
42
|
crack (0.4.5)
|
|
39
43
|
rexml
|
|
40
44
|
diff-lcs (1.4.4)
|
|
41
|
-
docile (1.
|
|
42
|
-
globalid (0.5.
|
|
45
|
+
docile (1.4.0)
|
|
46
|
+
globalid (0.5.2)
|
|
43
47
|
activesupport (>= 5.0)
|
|
44
48
|
hashdiff (1.0.1)
|
|
45
49
|
i18n (1.8.10)
|
|
@@ -47,6 +51,8 @@ GEM
|
|
|
47
51
|
jmespath (1.4.0)
|
|
48
52
|
method_source (1.0.0)
|
|
49
53
|
minitest (5.14.4)
|
|
54
|
+
mustermann (1.1.1)
|
|
55
|
+
ruby2_keywords (~> 0.0.1)
|
|
50
56
|
pry (0.13.1)
|
|
51
57
|
coderay (~> 1.1)
|
|
52
58
|
method_source (~> 1.0)
|
|
@@ -54,6 +60,9 @@ GEM
|
|
|
54
60
|
byebug (~> 11.0)
|
|
55
61
|
pry (~> 0.13.0)
|
|
56
62
|
public_suffix (4.0.6)
|
|
63
|
+
rack (2.2.3)
|
|
64
|
+
rack-protection (2.1.0)
|
|
65
|
+
rack
|
|
57
66
|
rake (12.3.3)
|
|
58
67
|
rexml (3.2.5)
|
|
59
68
|
rspec (3.10.0)
|
|
@@ -69,17 +78,25 @@ GEM
|
|
|
69
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
70
79
|
rspec-support (~> 3.10.0)
|
|
71
80
|
rspec-support (3.10.2)
|
|
81
|
+
ruby2_keywords (0.0.5)
|
|
72
82
|
simplecov (0.21.2)
|
|
73
83
|
docile (~> 1.1)
|
|
74
84
|
simplecov-html (~> 0.11)
|
|
75
85
|
simplecov_json_formatter (~> 0.1)
|
|
76
86
|
simplecov-html (0.12.3)
|
|
77
|
-
simplecov_json_formatter (0.1.
|
|
87
|
+
simplecov_json_formatter (0.1.3)
|
|
88
|
+
sinatra (2.1.0)
|
|
89
|
+
mustermann (~> 1.0)
|
|
90
|
+
rack (~> 2.2)
|
|
91
|
+
rack-protection (= 2.1.0)
|
|
92
|
+
tilt (~> 2.0)
|
|
78
93
|
thor (1.1.0)
|
|
94
|
+
tilt (2.0.10)
|
|
95
|
+
timecop (0.9.4)
|
|
79
96
|
tzinfo (2.0.4)
|
|
80
97
|
concurrent-ruby (~> 1.0)
|
|
81
|
-
webmock (3.
|
|
82
|
-
addressable (>= 2.
|
|
98
|
+
webmock (3.14.0)
|
|
99
|
+
addressable (>= 2.8.0)
|
|
83
100
|
crack (>= 0.3.2)
|
|
84
101
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
85
102
|
zeitwerk (2.4.2)
|
|
@@ -94,6 +111,8 @@ DEPENDENCIES
|
|
|
94
111
|
rake (~> 12.0)
|
|
95
112
|
rspec (~> 3.0)
|
|
96
113
|
simplecov
|
|
114
|
+
sinatra
|
|
115
|
+
timecop
|
|
97
116
|
webmock
|
|
98
117
|
|
|
99
118
|
BUNDLED WITH
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dotenv
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
3
|
+
|
|
4
|
+
ruby '~> 2.7'
|
|
5
|
+
|
|
6
|
+
# We use the 1.0 branch for it's circular dependency resolution,
|
|
7
|
+
# just because it's easy, and the classes in this project don't do
|
|
8
|
+
# anything fancy that would cause problems for it.
|
|
9
|
+
gem 'require_all', '~> 1.0'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# We're not using funktor as a regular gem because this is an app for testing funktor
|
|
13
|
+
# during development.
|
|
14
|
+
#
|
|
15
|
+
# gem 'funktor'
|
|
16
|
+
#
|
|
17
|
+
# Instead we're going to recreate the dependencies here so that we can use a local copy
|
|
18
|
+
# of the gem directly. TODO - Figure out if we can have this happen automatically so we
|
|
19
|
+
# don't have to keep things in sync.
|
|
20
|
+
|
|
21
|
+
gem 'aws-sdk-sqs', '~> 1.37'
|
|
22
|
+
gem 'aws-sdk-dynamodb', '~> 1.62'
|
|
23
|
+
gem "activesupport"
|
|
24
|
+
gem "thor" # Thor drives the CLI TODO - Maybe we don't need it here?
|
|
25
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: https://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
activesupport (6.1.4.1)
|
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
6
|
+
i18n (>= 1.6, < 2)
|
|
7
|
+
minitest (>= 5.1)
|
|
8
|
+
tzinfo (~> 2.0)
|
|
9
|
+
zeitwerk (~> 2.3)
|
|
10
|
+
aws-eventstream (1.1.1)
|
|
11
|
+
aws-partitions (1.488.0)
|
|
12
|
+
aws-sdk-core (3.119.0)
|
|
13
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
|
14
|
+
aws-partitions (~> 1, >= 1.239.0)
|
|
15
|
+
aws-sigv4 (~> 1.1)
|
|
16
|
+
jmespath (~> 1.0)
|
|
17
|
+
aws-sdk-dynamodb (1.62.0)
|
|
18
|
+
aws-sdk-core (~> 3, >= 3.119.0)
|
|
19
|
+
aws-sigv4 (~> 1.1)
|
|
20
|
+
aws-sdk-sqs (1.42.0)
|
|
21
|
+
aws-sdk-core (~> 3, >= 3.119.0)
|
|
22
|
+
aws-sigv4 (~> 1.1)
|
|
23
|
+
aws-sigv4 (1.2.4)
|
|
24
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
|
25
|
+
concurrent-ruby (1.1.9)
|
|
26
|
+
i18n (1.8.10)
|
|
27
|
+
concurrent-ruby (~> 1.0)
|
|
28
|
+
jmespath (1.4.0)
|
|
29
|
+
minitest (5.14.4)
|
|
30
|
+
require_all (1.5.0)
|
|
31
|
+
thor (1.1.0)
|
|
32
|
+
tzinfo (2.0.4)
|
|
33
|
+
concurrent-ruby (~> 1.0)
|
|
34
|
+
zeitwerk (2.4.2)
|
|
35
|
+
|
|
36
|
+
PLATFORMS
|
|
37
|
+
x86_64-darwin-20
|
|
38
|
+
x86_64-linux
|
|
39
|
+
|
|
40
|
+
DEPENDENCIES
|
|
41
|
+
activesupport
|
|
42
|
+
aws-sdk-dynamodb (~> 1.62)
|
|
43
|
+
aws-sdk-sqs (~> 1.37)
|
|
44
|
+
require_all (~> 1.0)
|
|
45
|
+
thor
|
|
46
|
+
|
|
47
|
+
RUBY VERSION
|
|
48
|
+
ruby 2.7.3p183
|
|
49
|
+
|
|
50
|
+
BUNDLED WITH
|
|
51
|
+
2.2.25
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
class JobFlood
|
|
2
|
+
attr_accessor :length_in_minutes
|
|
3
|
+
attr_accessor :min_jobs_per_minute
|
|
4
|
+
attr_accessor :max_jobs_per_minute
|
|
5
|
+
attr_accessor :max_job_length_in_seconds
|
|
6
|
+
attr_accessor :error_percentage
|
|
7
|
+
attr_accessor :error_percentage
|
|
8
|
+
|
|
9
|
+
def initialize length_in_minutes: 5, min_jobs_per_minute: 30, max_jobs_per_minute: 120, max_job_length_in_seconds: 3, error_percentage: 25
|
|
10
|
+
@length_in_minutes = length_in_minutes
|
|
11
|
+
@min_jobs_per_minute = min_jobs_per_minute
|
|
12
|
+
@max_jobs_per_minute = max_jobs_per_minute
|
|
13
|
+
@max_job_length_in_seconds = max_job_length_in_seconds
|
|
14
|
+
@error_percentage = error_percentage
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def flood
|
|
18
|
+
total_jobs = 0
|
|
19
|
+
length_in_minutes.times do |minute|
|
|
20
|
+
jobs_to_generate = rand(min_jobs_per_minute..max_jobs_per_minute)
|
|
21
|
+
jobs_to_generate.times do
|
|
22
|
+
total_jobs += 1
|
|
23
|
+
job_target_time = Time.now + (minute * 60) + rand(60)
|
|
24
|
+
job_sleep = rand(0.0..max_job_length_in_seconds.to_f)
|
|
25
|
+
puts job_target_time
|
|
26
|
+
[AuditWorker, AuditWorker, SingleThreadAuditWorker].sample.perform_at(job_target_time, {
|
|
27
|
+
mode: 'later',
|
|
28
|
+
message: 'msg: from random JobFlood - ' + SecureRandom.hex,
|
|
29
|
+
target_time: job_target_time,
|
|
30
|
+
error_percentage: error_percentage,
|
|
31
|
+
job_sleep: job_sleep
|
|
32
|
+
})
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
puts "generated #{total_jobs} jobs over the next #{length_in_minutes} minutes"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class AuditWorker
|
|
2
|
+
include Funktor::Worker
|
|
3
|
+
|
|
4
|
+
def perform(arg_hash)
|
|
5
|
+
time_now = Time.now
|
|
6
|
+
target_time = Time.parse arg_hash['target_time']
|
|
7
|
+
time_diff = time_now - target_time
|
|
8
|
+
Funktor.raw_logger.unknown Funktor.dump_json(metric_hash(time_diff))
|
|
9
|
+
|
|
10
|
+
puts "Greetings from the #{self.class.name}! Time diff = #{time_diff}"
|
|
11
|
+
puts arg_hash.class.name
|
|
12
|
+
puts arg_hash
|
|
13
|
+
|
|
14
|
+
if arg_hash["error_percentage"] && rand(100) < arg_hash["error_percentage"].to_i
|
|
15
|
+
raise "Oops, we encountered a 'random error'"
|
|
16
|
+
end
|
|
17
|
+
if arg_hash["job_sleep"]
|
|
18
|
+
puts "Working (sleeping) for #{arg_hash["job_sleep"]} seconds"
|
|
19
|
+
sleep arg_hash["job_sleep"]
|
|
20
|
+
end
|
|
21
|
+
puts "So long from the #{self.class.name}, and thanks for all the fish!"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def metric_hash(time_diff)
|
|
25
|
+
{
|
|
26
|
+
"_aws": {
|
|
27
|
+
"Timestamp": Time.now.strftime('%s%3N').to_i,
|
|
28
|
+
"CloudWatchMetrics": [
|
|
29
|
+
{
|
|
30
|
+
"Namespace": ENV['FUNKTOR_APP_NAME'],
|
|
31
|
+
"Dimensions": [["WorkerClassName"]],
|
|
32
|
+
"Metrics": [ # CPU, Memory, Duration, etc...
|
|
33
|
+
{
|
|
34
|
+
"Name": "TimeDiff",
|
|
35
|
+
"Unit": "Seconds"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"WorkerClassName": self.class.name,
|
|
42
|
+
"TimeDiff": time_diff
|
|
43
|
+
#"count": value,
|
|
44
|
+
#"requestId": "989ffbf8-9ace-4817-a57c-e4dd734019ee"
|
|
45
|
+
}
|
|
46
|
+
#data[key] = value
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class HelloWorker
|
|
2
|
+
include Funktor::Worker
|
|
3
|
+
|
|
4
|
+
def perform(arg_hash)
|
|
5
|
+
puts "Greetings from the #{self.class.name}!"
|
|
6
|
+
puts arg_hash.class.name
|
|
7
|
+
puts arg_hash
|
|
8
|
+
if arg_hash["error_percentage"] && rand(100) < arg_hash["error_percentage"].to_i
|
|
9
|
+
raise "Oops, we encountered a 'random error'"
|
|
10
|
+
end
|
|
11
|
+
if arg_hash["job_sleep"]
|
|
12
|
+
puts "Working (sleeping) for #{arg_hash["job_sleep"]} seconds"
|
|
13
|
+
sleep arg_hash["job_sleep"]
|
|
14
|
+
end
|
|
15
|
+
puts "So long from the #{self.class.name}, and thanks for all the fish!"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Point at our Gemfile
|
|
2
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
|
3
|
+
|
|
4
|
+
# load rubygems & bundler
|
|
5
|
+
require "rubygems"
|
|
6
|
+
require 'bundler/setup'
|
|
7
|
+
|
|
8
|
+
# Set up gems listed in the Gemfile.
|
|
9
|
+
Bundler.require(:default, :production)
|
|
10
|
+
|
|
11
|
+
# Here we load our development copy of funktor that we copy in using deploy-dev.sh
|
|
12
|
+
$LOAD_PATH.unshift 'funktor/lib'
|
|
13
|
+
require 'funktor'
|
|
14
|
+
|
|
15
|
+
# Load all ruby files in the app directory
|
|
16
|
+
require_rel File.join('..', 'app')
|
|
17
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
BUNDLE_WITHOUT: development:test:assets
|
|
2
|
+
BUNDLE_PLUGINS: false
|
|
3
|
+
BUNDLE_FROZEN: true
|
|
4
|
+
SERVERLESS_STAGE: ${self:custom.stage}
|
|
5
|
+
FUNKTOR_APP_NAME: funktor-testapp
|
|
6
|
+
FUNKTOR_INCOMING_JOB_QUEUE:
|
|
7
|
+
Ref: IncomingJobQueue
|
|
8
|
+
FUNKTOR_DEFAULT_QUEUE:
|
|
9
|
+
Ref: DefaultQueue
|
|
10
|
+
FUNKTOR_LOW_CONCURRENCY_QUEUE:
|
|
11
|
+
Ref: LowConcurrencyQueue
|
|
12
|
+
FUNKTOR_ACTIVITY_TABLE:
|
|
13
|
+
Ref: ActivityTable
|
|
14
|
+
FUNKTOR_JOBS_TABLE:
|
|
15
|
+
Ref: JobsTable
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
handler: lambda_event_handlers/default_queue_handler.call
|
|
2
|
+
timeout: ${self:custom.funktor.DefaultQueueHandler.functionTimeout, 900}
|
|
3
|
+
reservedConcurrency: ${self:custom.funktor.DefaultQueueHandler.reservedConcurrency, null}
|
|
4
|
+
provisionedConcurrency: ${self:custom.funktor.DefaultQueueHandler.provisionedConcurrency, null}
|
|
5
|
+
memorySize: ${self:custom.funktor.DefaultQueueHandler.memorySize, 256}
|
|
6
|
+
events:
|
|
7
|
+
- sqs:
|
|
8
|
+
batchSize: ${self:custom.funktor.DefaultQueueHandler.batchSize, 1}
|
|
9
|
+
maximumBatchingWindow: ${self:custom.funktor.DefaultQueueHandler.maximumBatchingWindow, 0}
|
|
10
|
+
arn:
|
|
11
|
+
Fn::GetAtt:
|
|
12
|
+
- DefaultQueue
|
|
13
|
+
- Arn
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
handler: lambda_event_handlers/incoming_job_handler.call
|
|
2
|
+
timeout: ${self:custom.funktor.IncomingJobHandler.functionTimeout, 30}
|
|
3
|
+
reservedConcurrency: ${self:custom.funktor.IncomingJobHandler.reservedConcurrency, null}
|
|
4
|
+
provisionedConcurrency: ${self:custom.funktor.IncomingJobHandler.provisionedConcurrency, null}
|
|
5
|
+
memorySize: ${self:custom.funktor.IncomingJobHandler.memorySize, 256}
|
|
6
|
+
events:
|
|
7
|
+
- sqs:
|
|
8
|
+
batchSize: ${self:custom.funktor.IncomingJobHandler.batchSize, 1}
|
|
9
|
+
maximumBatchingWindow: ${self:custom.funktor.IncomingJobHandler.maximumBatchingWindow, 0}
|
|
10
|
+
arn:
|
|
11
|
+
Fn::GetAtt:
|
|
12
|
+
- IncomingJobQueue
|
|
13
|
+
- Arn
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
handler: lambda_event_handlers/job_activator.call
|
|
2
|
+
timeout: ${self:custom.funktor.JobActivator.functionTimeout, 30}
|
|
3
|
+
reservedConcurrency: ${self:custom.funktor.JobActivator.reservedConcurrency, null}
|
|
4
|
+
provisionedConcurrency: ${self:custom.funktor.JobActivator.provisionedConcurrency, null}
|
|
5
|
+
memorySize: ${self:custom.funktor.JobActivator.memorySize, 256}
|
|
6
|
+
events:
|
|
7
|
+
- schedule: rate(1 minute)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
handler: lambda_event_handlers/low_concurrency_queue_handler.call
|
|
2
|
+
timeout: ${self:custom.funktor.LowConcurrencyQueueHandler.functionTimeout, 900}
|
|
3
|
+
reservedConcurrency: ${self:custom.funktor.LowConcurrencyQueueHandler.reservedConcurrency, null}
|
|
4
|
+
provisionedConcurrency: ${self:custom.funktor.LowConcurrencyQueueHandler.provisionedConcurrency, null}
|
|
5
|
+
memorySize: ${self:custom.funktor.LowConcurrencyQueueHandler.memorySize, 256}
|
|
6
|
+
events:
|
|
7
|
+
- sqs:
|
|
8
|
+
batchSize: ${self:custom.funktor.LowConcurrencyQueueHandler.batchSize, 1}
|
|
9
|
+
maximumBatchingWindow: ${self:custom.funktor.LowConcurrencyQueueHandler.maximumBatchingWindow, 0}
|
|
10
|
+
arn:
|
|
11
|
+
Fn::GetAtt:
|
|
12
|
+
- LowConcurrencyQueue
|
|
13
|
+
- Arn
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
handler: lambda_event_handlers/random_job_generator.RandomJobGenerator.call
|
|
2
|
+
timeout: 58
|
|
3
|
+
reservedConcurrency: 0
|
|
4
|
+
events:
|
|
5
|
+
- schedule: rate(1 minute)
|
|
6
|
+
environment:
|
|
7
|
+
# MAX_JOB_DELAY_IN_SECONDS controls the maximum delay that will be put on a randomly generated job.
|
|
8
|
+
MAX_JOB_DELAY_IN_SECONDS: 1200 # 20 minutes
|
|
9
|
+
# These values control how many random jobs will be generated per second. With extremely high values
|
|
10
|
+
# the generator may become limited by how quickly it can push to SQS. If you need to test LOTS of
|
|
11
|
+
# jobs you may want to set the tiemout to be longer and increase reservedConcurrency so that you
|
|
12
|
+
# can have multiple random generators running at one time.
|
|
13
|
+
MIN_RANDOM_JOBS_PER_MINUTE: 30
|
|
14
|
+
MAX_RANDOM_JOBS_PER_MINUTE: 120
|
|
15
|
+
# MAX_JOB_LENGTH_IN_SECONDS controls how long the slowest job will take to execute (by sleeping)
|
|
16
|
+
MAX_JOB_LENGTH_IN_SECONDS: 3
|
|
17
|
+
# ERROR_PERCENTAGE is the percent of requests that should raise an error and be retried.
|
|
18
|
+
ERROR_PERCENTAGE: 25
|