Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

feat: Improving the Context Helper #9

Merged
merged 5 commits into from
Mar 22, 2023
Merged

Conversation

klcodanr
Copy link
Contributor

  • Change to be class based
  • add new methods to better support SQS and request/transaction IDs

…ods to better support SQS and request/transaction IDs
@github-actions
Copy link

This PR will trigger a minor release when merged.

Copy link

@mfrisbey mfrisbey left a comment

Choose a reason for hiding this comment

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

Big +1 for using classes :)

My big concern is the leaking of SQS details to our processes.

src/context.js Outdated
* Gets the SQS records from the context
* @returns {Array<QueueRecord>} the SQS record payload
*/
extractSqsRecords() {

Choose a reason for hiding this comment

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

I worry about exposing details of the underlying execution platform. Why would any of our processes need to know whether they're running on SQS? That feels like a leak of implementation details that we shouldn't be relying on, and a strong coupling to SQS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very true, let me refactor this so it doesn't expose SQS details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the methods, but removed the SQS specifics from the name. Since the request structures differ, I think it still makes sense to have a method to see what "type" of request it is (e.g. standard HTTP vs Queue) because a HTTP request only contains 'event' but a queue request can contain many. The alternative would be to make the extractOriginalEvent method smarter and have it return an array or an item (or an array of one item), but that seems clunky.

@@ -11,6 +11,7 @@
*/

export * as contextHelper from './context.js';
export { ContextHelper } from './context.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

why are there two imports for context.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me try moving those into one, I kept the old export so it would be backwards compatible and marked all the old methods as deprecated so we can upgrade this without immediately refactoring a bunch of code (esp tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to be wrong here, but I don't see how to do this without two imports :-/

Copy link
Contributor

Choose a reason for hiding this comment

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

:/ that is fine. Just add a comment that one is for backwards compatibility

@klcodanr klcodanr requested review from mfrisbey and jdelbick March 22, 2023 14:01
@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #9 (8b0a7c0) into main (b3efb4d) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main        #9   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          621       703   +82     
=========================================
+ Hits           621       703   +82     
Impacted Files Coverage Δ
src/context.js 100.00% <100.00%> (ø)
src/index.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@klcodanr klcodanr merged commit 4ca0b02 into main Mar 22, 2023
@klcodanr klcodanr deleted the improve-context-helper-cp branch March 22, 2023 18:26
github-actions bot pushed a commit that referenced this pull request Mar 22, 2023
# [1.2.0](v1.1.0...v1.2.0) (2023-03-22)

### Features

* Improving the Context Helper ([#9](#9)) ([4ca0b02](4ca0b02))
@github-actions
Copy link

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants