Is it acceptable to use a golang struct return AND error return in a lambda triggered by SQS ?

Open
#425 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
aws, go
Domain
backend, cloud

Research direction

Start with the AWS Lambda Go SQS deployment example linked in the issue and compare it with the shown handler signatures. Verify the untested error-return behavior for an SQS-triggered invocation; done means the repository or its documentation clearly states whether the additional response value is accepted and how it affects SQS processing.

Written by the indexing model from the issue text.

Description

question

Hi,

https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-create-package.html#with-sqs-example-deployment-pkg-go

Lambda return signature to SQS in the example is :

func handler(ctx context.Context, sqsEvent events.SQSEvent) error {

Just a simple error return, with no struct.

However, to allow a lambda written in golang to provide more data when invoked outside of SQS, my code is returning an APIGatewayProxyResponse and an error. It is a feature of go to have multple return values, including an error.
I can invoke the lambda manually and see return values, rather than just nil, or have logs to go to Cloudwatch.

My interest in this is for testing - The lambda can return 'success data values or status', and an error for 'failure'.

func handle(ctx context.Context, sqsEvent events.SQSEvent) (events.APIGatewayProxyResponse, error) {

This is all working (error returns to SQS not tested, but not causing a problem either, I will test).

Thanks,

Marc

Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
16h 56m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-lambda-go

All issues in aws/aws-lambda-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.