Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create wrapper for SQSClient #9

Closed
wants to merge 6 commits into from
Closed

Conversation

dzehnder
Copy link
Contributor

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

Related Issues

Thanks for contributing!

@dzehnder dzehnder marked this pull request as ready for review October 19, 2023 09:53
Copy link
Member

@ekremney ekremney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add tests for both wrapper and the sqsqueue. We can also consider merging the two files into one (sqs-queue and sqs-wrapper) if makes sense

src/sqs-queue.js Outdated Show resolved Hide resolved
src/sqs-queue.js Outdated Show resolved Hide resolved
src/sqs-queue.js Outdated Show resolved Hide resolved
src/sqs-queue.js Outdated Show resolved Hide resolved
src/sqs-wrapper.js Outdated Show resolved Hide resolved
src/sqs-queue.js Outdated Show resolved Hide resolved
src/sqs-wrapper.js Outdated Show resolved Hide resolved
src/sqs-wrapper.js Outdated Show resolved Hide resolved
src/sqs-queue.js Outdated Show resolved Hide resolved
src/sqs-wrapper.js Outdated Show resolved Hide resolved
@github-actions
Copy link

This PR will trigger a minor release when merged.

src/index.js Outdated
return new Response('SUCCESS');
}

export const main = wrap(run)
.with(helixStatus)
.with(logger.trace)
.with(logger)
.with(secrets);
.with(secrets)
.with(queueWrapper);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secrets wrapper should be in outer level then queueWrapper otherwise queueWrapper won't have access to the env variables

throw new Error('AUDIT_RESULTS_QUEUE_URL env variable is empty/not provided');
}

context.queue = SqsQueue(region, queueUrl, log);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking: I would check if context.queue already defined here, and remove the if check in the SQSQueues constructor

Suggested change
context.queue = SqsQueue(region, queueUrl, log);
if (!context.queue) {
context.queue = SqsQueue(region, queueUrl, log);
}

see the suggestion below as well

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tripodsan thank you! @dzehnder let's stick to the same convention

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tripodsan could you give me access to helix-admin-support repo I don t seem to have it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We took a look and we will add the queue and storage to the context, but I think we shouldn t add it to the attributes, because I see the storage which is similar to db and queue is added directly to the context. Wdyt @tripodsan ?

src/sqs-queue.js Outdated
Comment on lines 16 to 20
export default function SQSQueue(region, queueUrl, log) {
if (!sqsClient) {
sqsClient = new SQSClient({ region });
log.info(`Creating SQS client in region ${region}`);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continues from the suggestion above

Suggested change
export default function SQSQueue(region, queueUrl, log) {
if (!sqsClient) {
sqsClient = new SQSClient({ region });
log.info(`Creating SQS client in region ${region}`);
}
export default function SQSQueue(region, queueUrl, log) {
const sqsClient = new SQSClient({ region });
log.info(`Creating SQS client in region ${region}`);

@dzehnder
Copy link
Contributor Author

Moved this PR content to #7 as it is depending on the changes from there

@dzehnder dzehnder closed this Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants