-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow short function names in queue consumer config (#1206)
Lambda Wrapper's current documentation for "direct"-mode offline SQS is incorrect: queue consumer names must be the full deployed function name generated by Serverless, typically `service-stage-FunctionName`, instead of just `FunctionName`. However, this approach is more difficult for the developer. In some of our services, this had been set up with hardcoded stage values, leading to unexpected issues when trying to simulate stages other than `dev` locally. This PR allows `SQSService` to add the necessary prefix to queue consumer function names, making the previously incorrect example in the documentation work. In order to maintain backwards compatibility, the prefix will not be added if it is already present. Correctly configured projects can continue to function, while projects that are broken (or broken in some stages where stage was hardcoded) will continue to be broken. Some design decisions: - I've placed the helper for getting the Lambda function name prefix into a public method of `DependencyInjection`, alongside the `isOffline` helper. It's not SQS-specific, and will be helpful in other scenarios where we want to invoke one Lambda function from another. - All changes in `SQSService` are within the `publishOffline` method. I initially considered mutating the SQS config object within the constructor so that all `queueConsumer` values were converted to full function names (requiring no changes to `publishOffline`). However, in a deployed environment, this creates unnecessary additional work within every Lambda invocation. Jira: [ENG-3396] [ENG-3396]: https://comicrelief.atlassian.net/browse/ENG-3396
- Loading branch information
Showing
6 changed files
with
109 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"functionName": "service-stage-FunctionName", | ||
"invokedFunctionArn": "offline" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters