You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The same Docker image will be used for both your `web` and `jobs` functions (example setup in following sections) which means the same `app.rb` handler would be used. The [Lamby](https://lamby.custominktech.com) gem automatically detects if Lambdakiq is being used so the following handler works as is.
60
-
61
-
```ruby
62
-
defhandler(event:, context:)
63
-
Lamby.handler $app, event, context
64
-
end
65
-
```
66
-
67
-
You can use the Lambdakiq handler directly in cases where your handler is a different method. Likewise there is a `Lambdakiq.jobs?(event)` helper function which returns true if the `messageAttributes` has a `lambdakiq` attribute.
68
-
69
-
```ruby
70
-
defjobs_handler(event:, context:)
71
-
Lambdakiq.handler(event)
72
-
end
73
-
```
59
+
The same Docker image will be used for both your `web` and `jobs` functions (example setup in following sections). The [Lamby](https://lamby.custominktech.com) gem can automatically can detect if Lambdakiq is present when using the newer `Lamby.cmd` or older lower `Lamby.handler` method. That said, please take a look at the `JobsLambda` in the following section and how `ImageConfig` is used as the golden path for sharing containers.
74
60
75
61
### SQS Resources
76
62
@@ -146,6 +132,8 @@ JobsLambda:
146
132
BatchSize: 1
147
133
FunctionResponseTypes:
148
134
- ReportBatchItemFailures
135
+
ImageConfig:
136
+
Command: ["config/environment.Lambdakiq.cmd"]
149
137
MemorySize: 1792
150
138
PackageType: Image
151
139
Policies:
@@ -161,6 +149,7 @@ JobsLambda:
161
149
162
150
Here are some key aspects of our `JobsLambda` resource above:
163
151
152
+
- We use the `ImageConfig.Command` to load your Rails env and invoke the `Lambdakiq.cmd` which calls the `Lambdakiq.handler` on your behalf.
164
153
- The `Events` property uses the [SQS Type](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-sqs.html).
165
154
- The [BatchSize](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-sqs.html#sam-function-sqs-batchsize) can be any number you like. Less means more Lambda concurrency, more means some jobs could take longer. The jobs function `Timeout` must be lower than the `JobsQueue`'s `VisibilityTimeout` property. When the batch size is one, the queue's visibility is generally one second more.
166
155
- You must use `ReportBatchItemFailures` response types. Lambdakiq assumes we are [reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting). This is a new feature of SQS introduced in [November 2021](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting).
0 commit comments