Skip to content

Commit 898ac8b

Browse files
authored
Document new Lambdakiq.cmd (#33)
1 parent 600cd65 commit 898ac8b

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
See this http://keepachangelog.com link for information on how we want this documented formatted.
44

5+
## v2.2.0
6+
7+
### Added
8+
9+
- Simple `Lambdakiq.cmd` to be used with `ImageConfig.Command`.
10+
511
## v2.1.0
612

713
#### Fixed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
lambdakiq (2.1.0)
4+
lambdakiq (2.2.0)
55
activejob
66
aws-sdk-sqs
77
concurrent-ruby

README.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,7 @@ ActionMailer::MailDeliveryJob.include Lambdakiq::Worker
5656
ActionMailer::MailDeliveryJob.queue_as ENV['JOBS_QUEUE_NAME']
5757
```
5858

59-
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-
def handler(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-
def jobs_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.
7460

7561
### SQS Resources
7662

@@ -146,6 +132,8 @@ JobsLambda:
146132
BatchSize: 1
147133
FunctionResponseTypes:
148134
- ReportBatchItemFailures
135+
ImageConfig:
136+
Command: ["config/environment.Lambdakiq.cmd"]
149137
MemorySize: 1792
150138
PackageType: Image
151139
Policies:
@@ -161,6 +149,7 @@ JobsLambda:
161149

162150
Here are some key aspects of our `JobsLambda` resource above:
163151

152+
- We use the `ImageConfig.Command` to load your Rails env and invoke the `Lambdakiq.cmd` which calls the `Lambdakiq.handler` on your behalf.
164153
- The `Events` property uses the [SQS Type](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-sqs.html).
165154
- 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.
166155
- 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).

lib/lambdakiq.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
module Lambdakiq
2222

23+
def cmd(event:, context:)
24+
handler(event)
25+
end
26+
2327
def handler(event)
2428
Job.handler(event)
2529
end

lib/lambdakiq/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Lambdakiq
2-
VERSION = '2.1.0'
2+
VERSION = '2.2.0'
33
end

0 commit comments

Comments
 (0)