-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
0066417
to
c33c171
Compare
9eb3d34
to
c623356
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial comments
const numberOfProvidersPresent = [awsPresent, azurePresent, gcpPresent, vercelPresent].filter( | ||
identity | ||
).length; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
gcp: applyGCPMetadata, | ||
azure: applyAzureMetadata, | ||
vercel: applyVercelMetadata, | ||
none: identity |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
)
export function identity<T>(obj: T): T { | ||
return obj; | ||
} |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
or identity
is commonly builtin with the semantics I provided. For example:
- http://www.lispworks.com/documentation/lw70/CLHS/Body/f_identi.htm#:~:text=identity%20is%20intended%20for%20use,is%20a%20number%20or%20character.
- https://clojuredocs.org/clojure.core/identity
- http://zvon.org/other/haskell/Outputprelude/id_f.html
I can remove it though if we want
Description
What is changing?
When present, FAAS metadata is included in the mongodb handshake.
Also included:
utils
file.MongoOptions
has a new option,truncatedClientMetadata
, to preserve the full metadata on themetadata
property while still only truncating the metadata once. The driver now uses thetruncatedMetadata
field internally.Is there new documentation needed for these changes?
No.
What is the motivation for this change?
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript