Skip to content

Add Deadline #27

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

Merged
merged 4 commits into from
Mar 10, 2020
Merged

Add Deadline #27

merged 4 commits into from
Mar 10, 2020

Conversation

fabianfett
Copy link
Member

@fabianfett fabianfett commented Mar 9, 2020

Motivation:

  • As a developer I want to be able to know how much time I have left to execute my lambda, before it times out

Changes:

  • storing the deadline as Int64 on Context and Invocation
  • added getRemainingTime() to Context which returns a NIO.TimeAmount
  • in the FoundationCompat library we should offer something based on Date
  • fixed MockLambdaServer to not return “keep-alive” anymore
  • renamed Invocation.deadlineDate to Invocation.deadline

This fixes #9

@fabianfett fabianfett requested a review from tomerd March 9, 2020 19:15
@fabianfett fabianfett force-pushed the add-deadline branch 3 times, most recently from 7a679c9 to 3f49f3b Compare March 9, 2020 19:19
public let logger: Logger

internal init(requestId: String,
traceId: String,
invokedFunctionArn: String,
deadline: String,
deadline: Int64,
Copy link
Contributor

Choose a reason for hiding this comment

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

what if we used DispatchWallTime instead of Int64? we can compute it in a similar way to getRemainingTime below, ie with a timespec: https://developer.apple.com/documentation/dispatch/dispatchwalltime/2300027-init

this way we can get rid of getRemainingTime and users (or the library) can compare deadline to DispatchWallTime.now etc

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to get it to work, but I still have no idea how to convert into the Unix epoch time. If you have a solution for this I’m glad to take it.

Copy link
Contributor

@tomerd tomerd Mar 10, 2020

Choose a reason for hiding this comment

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

@fabianfett added a commit with a proposal. feel free to revert it if you prefer the other way. also feel free to rename things, I dont love the names I picked

@tomerd tomerd force-pushed the add-deadline branch 4 times, most recently from 764dc5d to 820b4da Compare March 10, 2020 05:53
fabianfett and others added 3 commits March 10, 2020 16:32
Motivation:
- As a developer I want to be able to know how much time I have left to execute my lambda, before it times out

Changes:
- storing the deadline as Int64 on Context and Invocation
- added getRemainingTime() to Context which returns a TimeAmount
- in the FoundationCompat library we should offer something based on Date
- fixed MockLambdaServer to not return “keep-alive” anymore
- Renamed `Invocation.deadline` to `Invocation.deadlineInMillisSinceEpoch` to better reflect meaning.
- Added a test for `Context.getRemainingTime()`
@fabianfett
Copy link
Member Author

Added Context.getRemainingTime() back in. Otherwise very happy with this.

@tomerd
Copy link
Contributor

tomerd commented Mar 10, 2020

you can run the ./scripts/sanity.sh script locally to see what its complaining about, usually its formatting, missing linux tests (this case) or license headers

@tomerd tomerd merged commit d046617 into master Mar 10, 2020
@tomerd tomerd deleted the add-deadline branch March 10, 2020 17:30
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.

Replacing Date
2 participants