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(NODE-4696): include FAAS metadata in the mongodb handshake #3616

Closed
wants to merge 9 commits into from

Conversation

baileympearson
Copy link
Contributor

@baileympearson baileympearson commented Mar 30, 2023

Description

What is changing?

When present, FAAS metadata is included in the mongodb handshake.

Also included:

Is there new documentation needed for these changes?

No.

What is the motivation for this change?

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@baileympearson baileympearson force-pushed the NODE-4696-faas-metadata-handshake-5x branch from 0066417 to c33c171 Compare March 31, 2023 15:20
@baileympearson baileympearson force-pushed the NODE-4696-faas-metadata-handshake-5x branch from 9eb3d34 to c623356 Compare April 3, 2023 01:39
@baileympearson baileympearson changed the title fix metadata issue chore(NODE-4696): include FAAS metadata in the mongodb handshake Apr 3, 2023
@baileympearson baileympearson marked this pull request as ready for review April 3, 2023 12:50
@nbbeeken nbbeeken self-assigned this Apr 3, 2023
@nbbeeken nbbeeken added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Apr 3, 2023
@nbbeeken nbbeeken self-requested a review April 3, 2023 14:59
Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

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

Initial comments

src/cmap/handshake/client_metadata.ts Outdated Show resolved Hide resolved
Comment on lines +12 to +14
const numberOfProvidersPresent = [awsPresent, azurePresent, gcpPresent, vercelPresent].filter(
identity
).length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be an ifelse sequence instead?, we have the order encoded below with the early returns, I'd just add an else case to the end of that and return none.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, look closely at the logic. It purposefully returns none when there's more than one faas provider present

src/cmap/handshake/faas_provider.ts Outdated Show resolved Hide resolved
src/cmap/handshake/faas_provider.ts Outdated Show resolved Hide resolved
src/cmap/handshake/faas_provider.ts Outdated Show resolved Hide resolved
gcp: applyGCPMetadata,
azure: applyAzureMetadata,
vercel: applyVercelMetadata,
none: identity
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of adding a step for none, can't none do nothing to the input? maybe none could instead be represented by a null determineFAASProvider result that leads to returning the metadata input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

none does do nothing to the input, that's what identity is. I chose this over using null for simplicity in typing and edge casing. It flows everything through the same path logically

Copy link
Contributor

Choose a reason for hiding this comment

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

an early return based on null should narrow the key to be one of the acceptable strings, this way we can write less handling for the obvious case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That still requires handling for the obvious case, no? it's just that you've put it in a null check. I like this approach because there's no special casing values (or a "lack" of value here, indicated by none or null)

src/connection_string.ts Outdated Show resolved Hide resolved
src/sdam/topology.ts Outdated Show resolved Hide resolved
Comment on lines +1221 to +1223
export function identity<T>(obj: T): T {
return obj;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this provide that an inline arrow function does not? (Also I have suggestions that make this unnecessary)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typing and naming. It's used in two places

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't an arrow function provide the same type information? x => x should return the input type right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

src/cmap/handshake/client_metadata.ts Outdated Show resolved Hide resolved
@nbbeeken nbbeeken changed the title chore(NODE-4696): include FAAS metadata in the mongodb handshake feat(NODE-4696): include FAAS metadata in the mongodb handshake Apr 4, 2023
@nbbeeken
Copy link
Contributor

nbbeeken commented Apr 6, 2023

#3626

@nbbeeken nbbeeken closed this Apr 6, 2023
@nbbeeken nbbeeken deleted the NODE-4696-faas-metadata-handshake-5x branch September 11, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
2 participants