funktor 0.7.4 → 0.7.7
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 +11 -11
- data/funktor-testapp/Dockerfile +63 -0
- data/funktor-testapp/funktor_config/boot.rb +3 -0
- data/funktor-testapp/funktor_config/environment.yml +10 -1
- data/funktor-testapp/funktor_config/function_definitions/default_queue_handler.yml +5 -1
- data/funktor-testapp/funktor_config/function_definitions/incoming_job_handler.yml +5 -1
- data/funktor-testapp/funktor_config/function_definitions/job_activator.yml +5 -1
- data/funktor-testapp/funktor_config/function_definitions/low_concurrency_queue_handler.yml +5 -1
- data/funktor-testapp/funktor_config/package.yml +6 -6
- data/funktor-testapp/funktor_config/resources/cloudwatch_dashboard.yml +2 -2
- data/funktor-testapp/funktor_config/ruby_layer.yml +1 -1
- data/funktor-testapp/serverless.yml +13 -3
- data/lib/funktor/activity_tracker.rb +1 -2
- data/lib/funktor/cli/init.rb +4 -0
- data/lib/funktor/cli/templates/Dockerfile +63 -0
- data/lib/funktor/cli/templates/funktor_config/environment.yml +10 -1
- data/lib/funktor/cli/templates/funktor_config/function_definitions/incoming_job_handler.yml +5 -1
- data/lib/funktor/cli/templates/funktor_config/function_definitions/job_activator.yml +5 -1
- data/lib/funktor/cli/templates/funktor_config/function_definitions/work_queue_handler.yml +5 -1
- data/lib/funktor/cli/templates/funktor_config/package.yml +6 -6
- data/lib/funktor/cli/templates/funktor_config/resources/cloudwatch_dashboard.yml +1 -1
- data/lib/funktor/cli/templates/funktor_config/ruby_layer.yml +1 -1
- data/lib/funktor/cli/templates/serverless.yml +13 -3
- data/lib/funktor/incoming_job_handler.rb +9 -7
- data/lib/funktor/job_activator.rb +33 -17
- data/lib/funktor/job_pusher.rb +1 -1
- data/lib/funktor/version.rb +1 -1
- data/lib/funktor/web/application.rb +1 -1
- data/lib/funktor/work_queue_handler.rb +21 -6
- data/lib/funktor.rb +20 -1
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db4cbaf6480b6d6284a6370fbe9a87826647c72485ad75728ec7e28eae541836
|
|
4
|
+
data.tar.gz: 9b87f5a0ca280e84c4e321a8a86fa9926d32c420382737eb37ee59ca5f0cc73e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1bd98cffe465815f6aa168fc9ec81eee8c7bcda99e7d65e01116204ee55c415877b4125dc119c3ea6e8cc3d17126d123baabe06e03f7bca92112a64eb108a2fd
|
|
7
|
+
data.tar.gz: 86c0c79b8d031b88a623489160a04cfc3e2d115c5bf4d460011b8a6a4a3539810fb931a607f8ed27a3e9a174914671d367b3238d33aa0bf4e5da10029011f588
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
funktor (0.7.
|
|
4
|
+
funktor (0.7.7)
|
|
5
5
|
activesupport
|
|
6
6
|
aws-sdk-dynamodb (~> 1.62)
|
|
7
7
|
aws-sdk-sqs (~> 1.37)
|
|
@@ -22,19 +22,19 @@ GEM
|
|
|
22
22
|
addressable (2.8.0)
|
|
23
23
|
public_suffix (>= 2.0.2, < 5.0)
|
|
24
24
|
aws-eventstream (1.2.0)
|
|
25
|
-
aws-partitions (1.
|
|
26
|
-
aws-sdk-core (3.
|
|
25
|
+
aws-partitions (1.587.0)
|
|
26
|
+
aws-sdk-core (3.130.2)
|
|
27
27
|
aws-eventstream (~> 1, >= 1.0.2)
|
|
28
|
-
aws-partitions (~> 1, >= 1.
|
|
28
|
+
aws-partitions (~> 1, >= 1.525.0)
|
|
29
29
|
aws-sigv4 (~> 1.1)
|
|
30
30
|
jmespath (~> 1.0)
|
|
31
|
-
aws-sdk-dynamodb (1.
|
|
32
|
-
aws-sdk-core (~> 3, >= 3.
|
|
31
|
+
aws-sdk-dynamodb (1.74.0)
|
|
32
|
+
aws-sdk-core (~> 3, >= 3.127.0)
|
|
33
33
|
aws-sigv4 (~> 1.1)
|
|
34
|
-
aws-sdk-sqs (1.
|
|
35
|
-
aws-sdk-core (~> 3, >= 3.
|
|
34
|
+
aws-sdk-sqs (1.51.1)
|
|
35
|
+
aws-sdk-core (~> 3, >= 3.127.0)
|
|
36
36
|
aws-sigv4 (~> 1.1)
|
|
37
|
-
aws-sigv4 (1.
|
|
37
|
+
aws-sigv4 (1.5.0)
|
|
38
38
|
aws-eventstream (~> 1, >= 1.0.2)
|
|
39
39
|
byebug (11.1.3)
|
|
40
40
|
coderay (1.1.3)
|
|
@@ -48,7 +48,7 @@ GEM
|
|
|
48
48
|
hashdiff (1.0.1)
|
|
49
49
|
i18n (1.8.10)
|
|
50
50
|
concurrent-ruby (~> 1.0)
|
|
51
|
-
jmespath (1.
|
|
51
|
+
jmespath (1.6.1)
|
|
52
52
|
method_source (1.0.0)
|
|
53
53
|
minitest (5.14.4)
|
|
54
54
|
mustermann (1.1.1)
|
|
@@ -90,7 +90,7 @@ GEM
|
|
|
90
90
|
rack (~> 2.2)
|
|
91
91
|
rack-protection (= 2.1.0)
|
|
92
92
|
tilt (~> 2.0)
|
|
93
|
-
thor (1.1
|
|
93
|
+
thor (1.2.1)
|
|
94
94
|
tilt (2.0.10)
|
|
95
95
|
timecop (0.9.4)
|
|
96
96
|
tzinfo (2.0.4)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
FROM public.ecr.aws/lambda/ruby:2.7 AS build_image
|
|
2
|
+
|
|
3
|
+
# Uncomment this as a cache buster
|
|
4
|
+
#RUN echo date
|
|
5
|
+
|
|
6
|
+
# If you supplied buildArgs to the ecr image you can access them here using ARG & ENV
|
|
7
|
+
#ARG BUNDLE_GEM__FURY__IO
|
|
8
|
+
#ENV BUNDLE_GEM__FURY__IO=${BUNDLE_GEM__FURY__IO}
|
|
9
|
+
|
|
10
|
+
# First we install some stuff that we need for gems that have to compile native extensions
|
|
11
|
+
#RUN yum groupinstall "Development Tools" -y
|
|
12
|
+
#RUN yum install -y amazon-linux-extras
|
|
13
|
+
#RUN amazon-linux-extras enable postgresql11
|
|
14
|
+
#RUN yum install -y postgresql-devel
|
|
15
|
+
|
|
16
|
+
# Now we copy the Gemfile and Gemfile.lock into the build image so we can install our gems
|
|
17
|
+
COPY Gemfile Gemfile.lock .
|
|
18
|
+
|
|
19
|
+
# Set a few bundle configuration options
|
|
20
|
+
RUN bundle lock --add-platform x86_64-linux
|
|
21
|
+
#RUN bundle config --local deployment true
|
|
22
|
+
#RUN bundle config --local plugins false
|
|
23
|
+
#RUN bundle config --local frozen true
|
|
24
|
+
#RUN bundle config --local without 'development test'
|
|
25
|
+
RUN bundle config --local path './vendor/bundle'
|
|
26
|
+
|
|
27
|
+
# Now install our gems
|
|
28
|
+
RUN bundle install --quiet --jobs 4
|
|
29
|
+
|
|
30
|
+
# Now we start a second stage in the build that is a clean image without build tools
|
|
31
|
+
FROM public.ecr.aws/lambda/ruby:2.7 AS deploy_image
|
|
32
|
+
|
|
33
|
+
#ENV RAILS_ENV=production
|
|
34
|
+
#ENV RACK_ENV=production
|
|
35
|
+
|
|
36
|
+
# Install node so that asset related gems have a JS runtime.
|
|
37
|
+
# We ship the node executeable to production to make it easier to get an app deployed.
|
|
38
|
+
# TODO: Document steps that could be taken to remove this dependency.
|
|
39
|
+
#RUN curl --silent --location https://rpm.nodesource.com/setup_14.x | bash -
|
|
40
|
+
#RUN yum install -y nodejs
|
|
41
|
+
|
|
42
|
+
# Then copy some postgres related files
|
|
43
|
+
#COPY --from=build_image /usr/lib64/libpq.so.5 /usr/lib64/
|
|
44
|
+
#COPY --from=build_image /usr/lib64/libldap_r-2.4.so.2 /usr/lib64/
|
|
45
|
+
#COPY --from=build_image /usr/lib64/liblber-2.4.so.2 /usr/lib64/
|
|
46
|
+
#COPY --from=build_image /usr/lib64/libsasl2.so.3 /usr/lib64/
|
|
47
|
+
#COPY --from=build_image /usr/lib64/libssl3.so /usr/lib64/
|
|
48
|
+
#COPY --from=build_image /usr/lib64/libsmime3.so /usr/lib64/
|
|
49
|
+
#COPY --from=build_image /usr/lib64/libnss3.so /usr/lib64/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Next we copy the app from our local directory and we copy
|
|
53
|
+
# the bundled gems from the build image.
|
|
54
|
+
# We do this after copying dependencies becuase the app will
|
|
55
|
+
# change more frequently, and we can used caching up to here.
|
|
56
|
+
|
|
57
|
+
COPY --from=build_image /var/task .
|
|
58
|
+
COPY . .
|
|
59
|
+
|
|
60
|
+
# And finally we have the CMD for the deployed container
|
|
61
|
+
# You can overwrite command in `serverless.yml` template
|
|
62
|
+
CMD [ "app.LambdaFunction::Handler.process" ]
|
|
63
|
+
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
BUNDLE_WITHOUT: development:test
|
|
1
|
+
BUNDLE_WITHOUT: development:test
|
|
2
2
|
BUNDLE_PLUGINS: false
|
|
3
3
|
BUNDLE_FROZEN: true
|
|
4
|
+
BUNDLE_DEPLOYMENT: true
|
|
4
5
|
SERVERLESS_STAGE: ${self:custom.stage}
|
|
6
|
+
|
|
7
|
+
FUNKTOR_LOG_LEVEL: INFO
|
|
8
|
+
|
|
9
|
+
RAILS_LOG_TO_STDOUT: true
|
|
10
|
+
RAILS_ENV: production
|
|
11
|
+
RACK_ENV: production
|
|
12
|
+
RAILS_MAX_THREADS: 1
|
|
13
|
+
|
|
5
14
|
FUNKTOR_APP_NAME: funktor-testapp
|
|
6
15
|
FUNKTOR_INCOMING_JOB_QUEUE:
|
|
7
16
|
Ref: IncomingJobQueue
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
handler: lambda_event_handlers/default_queue_handler.call
|
|
1
|
+
#handler: lambda_event_handlers/default_queue_handler.call
|
|
2
2
|
timeout: ${self:custom.funktor.DefaultQueueHandler.functionTimeout, 900}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.DefaultQueueHandler.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.DefaultQueueHandler.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.DefaultQueueHandler.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/default_queue_handler.call
|
|
6
10
|
events:
|
|
7
11
|
- sqs:
|
|
8
12
|
batchSize: ${self:custom.funktor.DefaultQueueHandler.batchSize, 1}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
handler: lambda_event_handlers/incoming_job_handler.call
|
|
1
|
+
#handler: lambda_event_handlers/incoming_job_handler.call
|
|
2
2
|
timeout: ${self:custom.funktor.IncomingJobHandler.functionTimeout, 30}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.IncomingJobHandler.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.IncomingJobHandler.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.IncomingJobHandler.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/incoming_job_handler.call
|
|
6
10
|
events:
|
|
7
11
|
- sqs:
|
|
8
12
|
batchSize: ${self:custom.funktor.IncomingJobHandler.batchSize, 1}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
handler: lambda_event_handlers/job_activator.call
|
|
1
|
+
#handler: lambda_event_handlers/job_activator.call
|
|
2
2
|
timeout: ${self:custom.funktor.JobActivator.functionTimeout, 30}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.JobActivator.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.JobActivator.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.JobActivator.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/job_activator.call
|
|
6
10
|
events:
|
|
7
11
|
- schedule: rate(1 minute)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
handler: lambda_event_handlers/low_concurrency_queue_handler.call
|
|
1
|
+
#handler: lambda_event_handlers/low_concurrency_queue_handler.call
|
|
2
2
|
timeout: ${self:custom.funktor.LowConcurrencyQueueHandler.functionTimeout, 900}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.LowConcurrencyQueueHandler.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.LowConcurrencyQueueHandler.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.LowConcurrencyQueueHandler.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/low_concurrency_queue_handler.call
|
|
6
10
|
events:
|
|
7
11
|
- sqs:
|
|
8
12
|
batchSize: ${self:custom.funktor.LowConcurrencyQueueHandler.batchSize, 1}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# TODO - Figure out how to allow individual packaging to work out of the box.
|
|
2
|
-
individually: false
|
|
3
|
-
include:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
#individually: false
|
|
3
|
+
#include:
|
|
4
|
+
#- Gemfile
|
|
5
|
+
#- Gemfile.lock
|
|
6
|
+
#- funktor_config/boot.rb
|
|
7
|
+
#- app/**
|
|
8
8
|
# Evertyting is excluded by default with serverless-ruby-layer, but you could use
|
|
9
9
|
# the lines below to exlude files that are inside an include path.
|
|
10
10
|
#exclude:
|
|
@@ -117,17 +117,17 @@ Resources:
|
|
|
117
117
|
},
|
|
118
118
|
|
|
119
119
|
|
|
120
|
+
|
|
120
121
|
{
|
|
121
122
|
"height": 3,
|
|
122
123
|
"width": 24,
|
|
123
|
-
"y":
|
|
124
|
+
"y": 12,
|
|
124
125
|
"x": 0,
|
|
125
126
|
"type": "text",
|
|
126
127
|
"properties": {
|
|
127
128
|
"markdown": "\n# Behind the scenes\n\n The stats below give some insight into the inner workings of the Funktor apparatus."
|
|
128
129
|
}
|
|
129
130
|
},
|
|
130
|
-
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
|
|
@@ -25,6 +25,16 @@ provider:
|
|
|
25
25
|
runtime: ruby2.7
|
|
26
26
|
stage: ${opt:stage, 'dev'}
|
|
27
27
|
lambdaHashingVersion: 20201221
|
|
28
|
+
ecr:
|
|
29
|
+
scanOnPush: true
|
|
30
|
+
images:
|
|
31
|
+
funktorimage:
|
|
32
|
+
path: ./
|
|
33
|
+
file: Dockerfile
|
|
34
|
+
#platform: linux/amd64 # May be needed if you're on an M1.
|
|
35
|
+
buildArgs:
|
|
36
|
+
# Here you can specify ENV vars that you need at build time. For instance you may want to install private gems:
|
|
37
|
+
#BUNDLE_GEM__FURY__IO: ${env:BUNDLE_GEM__FURY__IO}
|
|
28
38
|
environment: ${file(funktor_config/environment.yml)}
|
|
29
39
|
versionFunctions: false # Reduces the amount of storage used since all Lambdas together are limited to 75GB
|
|
30
40
|
logRetentionInDays: 7
|
|
@@ -42,9 +52,9 @@ custom:
|
|
|
42
52
|
# commands. Or fallsback to what we have set in the provider section.
|
|
43
53
|
stage: ${self:provider.stage, 'dev'}
|
|
44
54
|
funktor: ${file(funktor_config/funktor.yml)}
|
|
45
|
-
rubyLayer: ${file(funktor_config/ruby_layer.yml)}
|
|
55
|
+
#rubyLayer: ${file(funktor_config/ruby_layer.yml)}
|
|
46
56
|
|
|
47
|
-
package: ${file(funktor_config/package.yml)}
|
|
57
|
+
#package: ${file(funktor_config/package.yml)}
|
|
48
58
|
|
|
49
59
|
functions:
|
|
50
60
|
IncomingJobHandler: ${file(funktor_config/function_definitions/incoming_job_handler.yml)}
|
|
@@ -62,4 +72,4 @@ resources:
|
|
|
62
72
|
- ${file(funktor_config/resources/jobs_table.yml)}
|
|
63
73
|
|
|
64
74
|
plugins:
|
|
65
|
-
|
|
75
|
+
#- serverless-ruby-layer
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'json'
|
|
2
|
-
require 'aws-sdk-dynamodb'
|
|
3
2
|
|
|
4
3
|
module Funktor
|
|
5
4
|
class ActivityTracker
|
|
@@ -74,7 +73,7 @@ module Funktor
|
|
|
74
73
|
end
|
|
75
74
|
|
|
76
75
|
def dynamodb_client
|
|
77
|
-
|
|
76
|
+
Funktor.dynamodb_client
|
|
78
77
|
end
|
|
79
78
|
|
|
80
79
|
def metric_namespace
|
data/lib/funktor/cli/init.rb
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
FROM public.ecr.aws/lambda/ruby:2.7 AS build_image
|
|
2
|
+
|
|
3
|
+
# Uncomment this as a cache buster
|
|
4
|
+
#RUN echo date
|
|
5
|
+
|
|
6
|
+
# If you supplied buildArgs to the ecr image you can access them here using ARG & ENV
|
|
7
|
+
#ARG BUNDLE_GEM__FURY__IO
|
|
8
|
+
#ENV BUNDLE_GEM__FURY__IO=${BUNDLE_GEM__FURY__IO}
|
|
9
|
+
|
|
10
|
+
# First we install some stuff that we need for gems that have to compile native extensions
|
|
11
|
+
#RUN yum groupinstall "Development Tools" -y
|
|
12
|
+
#RUN yum install -y amazon-linux-extras
|
|
13
|
+
#RUN amazon-linux-extras enable postgresql11
|
|
14
|
+
#RUN yum install -y postgresql-devel
|
|
15
|
+
|
|
16
|
+
# Now we copy the Gemfile and Gemfile.lock into the build image so we can install our gems
|
|
17
|
+
COPY Gemfile Gemfile.lock .
|
|
18
|
+
|
|
19
|
+
# Set a few bundle configuration options
|
|
20
|
+
RUN bundle lock --add-platform x86_64-linux
|
|
21
|
+
#RUN bundle config --local deployment true
|
|
22
|
+
#RUN bundle config --local plugins false
|
|
23
|
+
#RUN bundle config --local frozen true
|
|
24
|
+
#RUN bundle config --local without 'development test'
|
|
25
|
+
RUN bundle config --local path './vendor/bundle'
|
|
26
|
+
|
|
27
|
+
# Now install our gems
|
|
28
|
+
RUN bundle install --quiet --jobs 4
|
|
29
|
+
|
|
30
|
+
# Now we start a second stage in the build that is a clean image without build tools
|
|
31
|
+
FROM public.ecr.aws/lambda/ruby:2.7 AS deploy_image
|
|
32
|
+
|
|
33
|
+
#ENV RAILS_ENV=production
|
|
34
|
+
#ENV RACK_ENV=production
|
|
35
|
+
|
|
36
|
+
# Install node so that asset related gems have a JS runtime.
|
|
37
|
+
# We ship the node executeable to production to make it easier to get an app deployed.
|
|
38
|
+
# TODO: Document steps that could be taken to remove this dependency.
|
|
39
|
+
#RUN curl --silent --location https://rpm.nodesource.com/setup_14.x | bash -
|
|
40
|
+
#RUN yum install -y nodejs
|
|
41
|
+
|
|
42
|
+
# Then copy some postgres related files
|
|
43
|
+
#COPY --from=build_image /usr/lib64/libpq.so.5 /usr/lib64/
|
|
44
|
+
#COPY --from=build_image /usr/lib64/libldap_r-2.4.so.2 /usr/lib64/
|
|
45
|
+
#COPY --from=build_image /usr/lib64/liblber-2.4.so.2 /usr/lib64/
|
|
46
|
+
#COPY --from=build_image /usr/lib64/libsasl2.so.3 /usr/lib64/
|
|
47
|
+
#COPY --from=build_image /usr/lib64/libssl3.so /usr/lib64/
|
|
48
|
+
#COPY --from=build_image /usr/lib64/libsmime3.so /usr/lib64/
|
|
49
|
+
#COPY --from=build_image /usr/lib64/libnss3.so /usr/lib64/
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# Next we copy the app from our local directory and we copy
|
|
53
|
+
# the bundled gems from the build image.
|
|
54
|
+
# We do this after copying dependencies becuase the app will
|
|
55
|
+
# change more frequently, and we can used caching up to here.
|
|
56
|
+
|
|
57
|
+
COPY --from=build_image /var/task .
|
|
58
|
+
COPY . .
|
|
59
|
+
|
|
60
|
+
# And finally we have the CMD for the deployed container
|
|
61
|
+
# You can overwrite command in `serverless.yml` template
|
|
62
|
+
CMD [ "app.LambdaFunction::Handler.process" ]
|
|
63
|
+
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
BUNDLE_WITHOUT: development:test
|
|
1
|
+
BUNDLE_WITHOUT: development:test
|
|
2
2
|
BUNDLE_PLUGINS: false
|
|
3
3
|
BUNDLE_FROZEN: true
|
|
4
|
+
BUNDLE_DEPLOYMENT: true
|
|
4
5
|
SERVERLESS_STAGE: ${self:custom.stage}
|
|
6
|
+
|
|
7
|
+
FUNKTOR_LOG_LEVEL: INFO
|
|
8
|
+
|
|
9
|
+
RAILS_LOG_TO_STDOUT: true
|
|
10
|
+
RAILS_ENV: production
|
|
11
|
+
RACK_ENV: production
|
|
12
|
+
RAILS_MAX_THREADS: 1
|
|
13
|
+
|
|
5
14
|
FUNKTOR_APP_NAME: <%= app_name %>
|
|
6
15
|
FUNKTOR_INCOMING_JOB_QUEUE:
|
|
7
16
|
Ref: IncomingJobQueue
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
handler: lambda_event_handlers/incoming_job_handler.call
|
|
1
|
+
#handler: lambda_event_handlers/incoming_job_handler.call
|
|
2
2
|
timeout: ${self:custom.funktor.IncomingJobHandler.functionTimeout, 30}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.IncomingJobHandler.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.IncomingJobHandler.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.IncomingJobHandler.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/incoming_job_handler.call
|
|
6
10
|
events:
|
|
7
11
|
- sqs:
|
|
8
12
|
batchSize: ${self:custom.funktor.IncomingJobHandler.batchSize, 1}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
handler: lambda_event_handlers/job_activator.call
|
|
1
|
+
#handler: lambda_event_handlers/job_activator.call
|
|
2
2
|
timeout: ${self:custom.funktor.JobActivator.functionTimeout, 30}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.JobActivator.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.JobActivator.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.JobActivator.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/job_activator.call
|
|
6
10
|
events:
|
|
7
11
|
- schedule: rate(1 minute)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
handler: lambda_event_handlers/<%= work_queue_name.underscore %>_queue_handler.call
|
|
1
|
+
#handler: lambda_event_handlers/<%= work_queue_name.underscore %>_queue_handler.call
|
|
2
2
|
timeout: ${self:custom.funktor.<%= work_queue_name.camelize %>QueueHandler.functionTimeout, 900}
|
|
3
3
|
reservedConcurrency: ${self:custom.funktor.<%= work_queue_name.camelize %>QueueHandler.reservedConcurrency, null}
|
|
4
4
|
provisionedConcurrency: ${self:custom.funktor.<%= work_queue_name.camelize %>QueueHandler.provisionedConcurrency, null}
|
|
5
5
|
memorySize: ${self:custom.funktor.<%= work_queue_name.camelize %>QueueHandler.memorySize, 256}
|
|
6
|
+
image:
|
|
7
|
+
name: funktorimage
|
|
8
|
+
command:
|
|
9
|
+
- lambda_event_handlers/<%= work_queue_name.underscore %>_queue_handler.call
|
|
6
10
|
events:
|
|
7
11
|
- sqs:
|
|
8
12
|
batchSize: ${self:custom.funktor.<%= work_queue_name.camelize %>QueueHandler.batchSize, 1}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# TODO - Figure out how to allow individual packaging to work out of the box.
|
|
2
|
-
individually: false
|
|
3
|
-
include:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
#individually: false
|
|
3
|
+
#include:
|
|
4
|
+
#- Gemfile
|
|
5
|
+
#- Gemfile.lock
|
|
6
|
+
#- funktor_config/boot.rb
|
|
7
|
+
#- app/**
|
|
8
8
|
# Evertyting is excluded by default with serverless-ruby-layer, but you could use
|
|
9
9
|
# the lines below to exlude files that are inside an include path.
|
|
10
10
|
#exclude:
|
|
@@ -109,6 +109,7 @@ Resources:
|
|
|
109
109
|
},
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
<% current_y += 3 %>
|
|
112
113
|
{ <% "Funktor Behind the Scenes Banner" %>
|
|
113
114
|
"height": 3,
|
|
114
115
|
"width": 24,
|
|
@@ -119,7 +120,6 @@ Resources:
|
|
|
119
120
|
"markdown": "\n# Behind the scenes\n\n The stats below give some insight into the inner workings of the Funktor apparatus."
|
|
120
121
|
}
|
|
121
122
|
},
|
|
122
|
-
<% current_y += 3 %>
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
<% current_y += 6 %>
|
|
@@ -25,6 +25,16 @@ provider:
|
|
|
25
25
|
runtime: <%= runtime %>
|
|
26
26
|
stage: ${opt:stage, 'dev'}
|
|
27
27
|
lambdaHashingVersion: 20201221
|
|
28
|
+
ecr:
|
|
29
|
+
scanOnPush: true
|
|
30
|
+
images:
|
|
31
|
+
funktorimage:
|
|
32
|
+
path: ./
|
|
33
|
+
file: Dockerfile
|
|
34
|
+
#platform: linux/amd64 # May be needed if you're on an M1.
|
|
35
|
+
buildArgs:
|
|
36
|
+
# Here you can specify ENV vars that you need at build time. For instance you may want to install private gems:
|
|
37
|
+
#BUNDLE_GEM__FURY__IO: ${env:BUNDLE_GEM__FURY__IO}
|
|
28
38
|
environment: ${file(funktor_config/environment.yml)}
|
|
29
39
|
versionFunctions: false # Reduces the amount of storage used since all Lambdas together are limited to 75GB
|
|
30
40
|
logRetentionInDays: 7
|
|
@@ -39,9 +49,9 @@ custom:
|
|
|
39
49
|
# commands. Or fallsback to what we have set in the provider section.
|
|
40
50
|
stage: ${self:provider.stage, 'dev'}
|
|
41
51
|
funktor: ${file(funktor_config/funktor.yml)}
|
|
42
|
-
rubyLayer: ${file(funktor_config/ruby_layer.yml)}
|
|
52
|
+
#rubyLayer: ${file(funktor_config/ruby_layer.yml)}
|
|
43
53
|
|
|
44
|
-
package: ${file(funktor_config/package.yml)}
|
|
54
|
+
#package: ${file(funktor_config/package.yml)}
|
|
45
55
|
|
|
46
56
|
functions:
|
|
47
57
|
<%- all_function_definitions.each do |function_definition| -%>
|
|
@@ -54,4 +64,4 @@ resources:
|
|
|
54
64
|
<%- end -%>
|
|
55
65
|
|
|
56
66
|
plugins:
|
|
57
|
-
|
|
67
|
+
#- serverless-ruby-layer
|
|
@@ -18,11 +18,11 @@ module Funktor
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def sqs_client
|
|
21
|
-
|
|
21
|
+
Funktor.sqs_client
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def dynamodb_client
|
|
25
|
-
|
|
25
|
+
Funktor.dynamodb_client
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def dispatch(job)
|
|
@@ -30,11 +30,13 @@ module Funktor
|
|
|
30
30
|
# TODO : This number should be configurable via ENV var
|
|
31
31
|
if job.delay < 60 # for now we're testing with just one minute * 5 # 5 minutes
|
|
32
32
|
Funktor.logger.debug "pushing to work queue for delay = #{job.delay}"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
if Funktor.enable_work_queue_visibility
|
|
34
|
+
# We push to the jobs table first becauase the work queue handler will expect to be able
|
|
35
|
+
# to update the stats of a record that's already in the table.
|
|
36
|
+
# TODO : For time sensitive jobs this is probably less than optimal. Can we update the
|
|
37
|
+
# work queue handler to be ok with a job that's not yet in the table?
|
|
38
|
+
push_to_jobs_table(job, "queued")
|
|
39
|
+
end
|
|
38
40
|
push_to_work_queue(job)
|
|
39
41
|
if job.is_retry?
|
|
40
42
|
@tracker.track(:retryActivated, job)
|
|
@@ -9,11 +9,11 @@ module Funktor
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def dynamodb_client
|
|
12
|
-
|
|
12
|
+
Funktor.dynamodb_client
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def sqs_client
|
|
16
|
-
|
|
16
|
+
Funktor.sqs_client
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def delayed_job_table
|
|
@@ -61,23 +61,39 @@ module Funktor
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def activate_job(job_shard, job_id, current_category, queue_immediately = false)
|
|
64
|
+
# TODO: WorkQueueVisibilityMiddleware to alter what happens here? Maybe we delete by default and then the middleware puts it back in the table?
|
|
64
65
|
# First we conditionally update the item in Dynamo to be sure that another scheduler hasn't gotten
|
|
65
66
|
# to it, and if that works then send to SQS. This is basically how Sidekiq scheduler works.
|
|
66
|
-
response =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
response = if Funktor.enable_work_queue_visibility
|
|
68
|
+
dynamodb_client.update_item({
|
|
69
|
+
key: {
|
|
70
|
+
"jobShard" => job_shard,
|
|
71
|
+
"jobId" => job_id
|
|
72
|
+
},
|
|
73
|
+
update_expression: "SET category = :category, queueable = :queueable",
|
|
74
|
+
condition_expression: "category = :current_category",
|
|
75
|
+
expression_attribute_values: {
|
|
76
|
+
":current_category" => current_category,
|
|
77
|
+
":queueable" => "false",
|
|
78
|
+
":category" => "queued"
|
|
79
|
+
},
|
|
80
|
+
table_name: delayed_job_table,
|
|
81
|
+
return_values: "ALL_OLD"
|
|
82
|
+
})
|
|
83
|
+
else
|
|
84
|
+
dynamodb_client.delete_item({
|
|
85
|
+
key: {
|
|
86
|
+
"jobShard" => job_shard,
|
|
87
|
+
"jobId" => job_id
|
|
88
|
+
},
|
|
89
|
+
condition_expression: "category = :current_category",
|
|
90
|
+
expression_attribute_values: {
|
|
91
|
+
":current_category" => current_category
|
|
92
|
+
},
|
|
93
|
+
table_name: delayed_job_table,
|
|
94
|
+
return_values: "ALL_OLD"
|
|
95
|
+
})
|
|
96
|
+
end
|
|
81
97
|
if response.attributes # this means the record was still there in the state we expected
|
|
82
98
|
Funktor.logger.debug "response.attributes ====== "
|
|
83
99
|
Funktor.logger.debug response.attributes
|
data/lib/funktor/job_pusher.rb
CHANGED
data/lib/funktor/version.rb
CHANGED
|
@@ -20,23 +20,28 @@ module Funktor
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def dynamodb_client
|
|
23
|
-
|
|
23
|
+
Funktor.dynamodb_client
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def sqs_client
|
|
27
|
-
|
|
27
|
+
Funktor.sqs_client
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def dispatch(job)
|
|
31
31
|
begin
|
|
32
32
|
@tracker.track(:processingStarted, job)
|
|
33
|
-
|
|
33
|
+
if Funktor.enable_work_queue_visibility
|
|
34
|
+
update_job_category(job, "processing")
|
|
35
|
+
end
|
|
34
36
|
Funktor.work_queue_handler_middleware.invoke(job) do
|
|
35
37
|
job.execute
|
|
36
38
|
end
|
|
37
39
|
@processed_counter.incr(job)
|
|
38
40
|
@tracker.track(:processingComplete, job)
|
|
39
|
-
|
|
41
|
+
|
|
42
|
+
if Funktor.enable_work_queue_visibility
|
|
43
|
+
delete_job_from_dynamodb(job)
|
|
44
|
+
end
|
|
40
45
|
# rescue Funktor::Job::InvalidJsonError # TODO Make this work
|
|
41
46
|
rescue Exception => e
|
|
42
47
|
handle_error(e, job)
|
|
@@ -44,11 +49,17 @@ module Funktor
|
|
|
44
49
|
job.error = e
|
|
45
50
|
if job.can_retry
|
|
46
51
|
@tracker.track(:retrying, job)
|
|
47
|
-
|
|
52
|
+
|
|
53
|
+
if Funktor.enable_work_queue_visibility
|
|
54
|
+
update_job_category(job, "retry")
|
|
55
|
+
end
|
|
48
56
|
trigger_retry(job)
|
|
49
57
|
else
|
|
50
58
|
@tracker.track(:bailingOut, job)
|
|
51
|
-
|
|
59
|
+
|
|
60
|
+
if Funktor.enable_work_queue_visibility
|
|
61
|
+
update_job_category(job, "dead")
|
|
62
|
+
end
|
|
52
63
|
Funktor.logger.error "We retried max times. We're bailing on this one."
|
|
53
64
|
Funktor.logger.error job.to_json
|
|
54
65
|
end
|
|
@@ -71,6 +82,7 @@ module Funktor
|
|
|
71
82
|
end
|
|
72
83
|
|
|
73
84
|
def update_job_category(job, category)
|
|
85
|
+
puts "starting update_job_category #{category}"
|
|
74
86
|
dynamodb_client.update_item({
|
|
75
87
|
key: {
|
|
76
88
|
"jobShard" => job.shard,
|
|
@@ -84,9 +96,11 @@ module Funktor
|
|
|
84
96
|
},
|
|
85
97
|
return_values: "ALL_OLD"
|
|
86
98
|
})
|
|
99
|
+
puts "ending update_job_category #{category}"
|
|
87
100
|
end
|
|
88
101
|
|
|
89
102
|
def delete_job_from_dynamodb(job)
|
|
103
|
+
puts "starting delete_job_from_dynamodb"
|
|
90
104
|
dynamodb_client.delete_item({
|
|
91
105
|
key: {
|
|
92
106
|
"jobShard" => job.shard,
|
|
@@ -95,6 +109,7 @@ module Funktor
|
|
|
95
109
|
table_name: delayed_job_table,
|
|
96
110
|
return_values: "ALL_OLD"
|
|
97
111
|
})
|
|
112
|
+
puts "ending delete_job_from_dynamodb"
|
|
98
113
|
end
|
|
99
114
|
|
|
100
115
|
end
|
data/lib/funktor.rb
CHANGED
|
@@ -12,13 +12,16 @@ require_relative 'funktor/job_activator'
|
|
|
12
12
|
require_relative 'funktor/activity_tracker'
|
|
13
13
|
|
|
14
14
|
require 'json'
|
|
15
|
+
require 'aws-sdk-dynamodb'
|
|
16
|
+
require 'aws-sdk-sqs'
|
|
15
17
|
|
|
16
18
|
module Funktor
|
|
17
19
|
class Error < StandardError; end
|
|
18
20
|
|
|
19
21
|
DEFAULT_OPTIONS = {
|
|
20
22
|
error_handlers: [],
|
|
21
|
-
log_level: Logger::DEBUG # Set a high log level during early, active development
|
|
23
|
+
log_level: Logger::DEBUG, # Set a high log level during early, active development
|
|
24
|
+
enable_work_queue_visibility: true # Enable this by default during early, active development
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
def self.configure_job_pusher
|
|
@@ -110,6 +113,14 @@ module Funktor
|
|
|
110
113
|
@logger = logger
|
|
111
114
|
end
|
|
112
115
|
|
|
116
|
+
def self.enable_work_queue_visibility
|
|
117
|
+
options[:enable_work_queue_visibility]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def self.enable_work_queue_visibility= enabled
|
|
121
|
+
options[:enable_work_queue_visibility] = enabled
|
|
122
|
+
end
|
|
123
|
+
|
|
113
124
|
# We have a raw_logger that doesn't add timestamps and what not. This is used to publish
|
|
114
125
|
# CloudWatch metrics that can be used in dashboards.
|
|
115
126
|
def self.raw_logger
|
|
@@ -126,6 +137,14 @@ module Funktor
|
|
|
126
137
|
|
|
127
138
|
@raw_logger = raw_logger
|
|
128
139
|
end
|
|
140
|
+
|
|
141
|
+
def self.dynamodb_client
|
|
142
|
+
@dynamodb_client ||= ::Aws::DynamoDB::Client.new
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.sqs_client
|
|
146
|
+
@sqs_client ||= ::Aws::SQS::Client.new
|
|
147
|
+
end
|
|
129
148
|
end
|
|
130
149
|
|
|
131
150
|
# TODO - Is it a code smell that we need to include these at the bottom, after
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: funktor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Green
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-05-
|
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-sqs
|
|
@@ -176,6 +176,7 @@ files:
|
|
|
176
176
|
- exe/funktor-deploy
|
|
177
177
|
- funktor-testapp/.envrc
|
|
178
178
|
- funktor-testapp/.gitignore
|
|
179
|
+
- funktor-testapp/Dockerfile
|
|
179
180
|
- funktor-testapp/Gemfile
|
|
180
181
|
- funktor-testapp/Gemfile.lock
|
|
181
182
|
- funktor-testapp/app/services/job_flood.rb
|
|
@@ -227,6 +228,7 @@ files:
|
|
|
227
228
|
- lib/funktor/cli/generate/base.rb
|
|
228
229
|
- lib/funktor/cli/generate/work_queue.rb
|
|
229
230
|
- lib/funktor/cli/init.rb
|
|
231
|
+
- lib/funktor/cli/templates/Dockerfile
|
|
230
232
|
- lib/funktor/cli/templates/Gemfile
|
|
231
233
|
- lib/funktor/cli/templates/app/workers/hello_worker.rb
|
|
232
234
|
- lib/funktor/cli/templates/funktor_config/boot.rb
|