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

Add typing to proto converters and fix breaks #4544

Closed
wants to merge 5 commits into from

Conversation

inlined
Copy link
Member

@inlined inlined commented May 12, 2022

After fixing #4543 I decided that I now know how to make proto.renameIfPresent more strongly typed and made a change that would have caught the error before it was ever a bug.

Did that and started fixing the build breaks it caught. Since I noticed a lot of converter code for build was using the same key name, I also added proto.convertIfPresent.

The build code was broken for scheduled functions. That's because the old triggerParser uses durations whereas the container contract uses seconds (so we can use number params). The code looks extra wonky because backend.Backend also uses durations. As an exercise for the reader, someone should probably make backend.Backend use seconds and convert to/from duration in endpointFromFunction and functionFromEndpoint. duration is silly and should be in as little of our type system as possible.

@bkendall bkendall changed the base branch from next to master May 17, 2022 18:22
Copy link
Contributor

@colerogers colerogers left a comment

Choose a reason for hiding this comment

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

Couple Q's

"minBackoffSeconds",
(seconds) => proto.durationFromSeconds(resolveInt(seconds))
);
proto.renameIfPresent(
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this identical to L374?

Copy link
Member Author

Choose a reason for hiding this comment

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

yup

return bytes / (1 << 20);
bytes = bytes / (1 << 20);
const typed = bytes as backend.MemoryOptions;
if (backend.AllMemoryOptions.includes(typed)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should there be a ! here? like if typed is not in AllMemoryOptions then we'd throw a warning

Copy link
Member Author

Choose a reason for hiding this comment

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

yup

@inlined inlined closed this Aug 30, 2022
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.

None yet

3 participants