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

Implement CallHttp Polling Replay Logic #346

Merged
merged 6 commits into from
May 20, 2022
Merged

Conversation

hossam-nasr
Copy link
Contributor

@hossam-nasr hossam-nasr commented Apr 19, 2022

Resolves #284 . This PR:

  • Adds the asynchronousPatternEnabled property to DurableHttpRequest, which is expected by the extension and enable polling logic
  • Accepts the defaultHttpAsyncRequestSleepTimeMillseconds from the extension payload, which specifies the default period to wait between polling requests (Extension PR: Send Default Async HTTP Request Sleep Time in OOProc Payload azure-functions-durable-extension#2142)
  • Introduces a new CompoundTask, the CallHttpWithPollingTask, which implements the logic for creating timers and new CallHttpActions when polling is enabled
  • In CallHttp
    • If polling is enabled, a CallHttpWithPollingTask is returned, else a normal AtomicTask is returned
  • In CallHttpWithPollingTask's trySetValue:
    • If the response code is 202 and the Location header is set, a new timer task and new call http task are created and added to the children
    • If any other response is given, it is set as the result of the entire task
    • If any child task fails, the entire compound task fails

Some questions/concerns:

  • Do we need to worry about case sensitivity for HTTP headers? There are two places where we use headers: the Location header to determine whether to poll, and the Retry-After header to determine the timeout between polling requests. Currently they are case insensitive, but I'm not sure if we should be more lenient about this. As far as I could tell, extension code was also case insensitive, but I might be wrong.
  • Should we make asynchronousPatternEnabled true by default? On the one hand, technically this isn't a new feature, but rather a bug in the previous implementation, and polling should've worked out of the box, so it makes sense to make it true by default (it is also true by default on the extension side), but on the other hand, if some customers were returning some 202 response code without intending to poll, they would now get unexpected behavior.
  • Similarly, I also had a similar guard and error here that I used for the long timers, essentially blocking this feature unless replay schema V3 is being used. However, this is slightly different from the long timers in that it doesn't require any logical changes on the extension side. So, should I instead allow this to be used with replay schema < V3, and use some default value (perhaps the same default value used by the extension, bearing in mind that in the future, they could end up out of sync) for defaultHttpAsyncRequestSleepTimeMillseconds?

@hossam-nasr hossam-nasr force-pushed the hossamnasr/callhttp-polling branch 2 times, most recently from 545604f to ea39df4 Compare April 19, 2022 19:15
@hossam-nasr hossam-nasr changed the title Hossamnasr/callhttp polling Implement CallHttp Polling Replay Logic Apr 19, 2022
@hossam-nasr hossam-nasr marked this pull request as ready for review April 19, 2022 19:34
Copy link
Collaborator

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

This looks great, but don't have a polling test yet, right?

src/durableorchestrationcontext.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

It's looking good to me, we just need a test :-)

src/task.ts Show resolved Hide resolved
@davidmrdavid
Copy link
Collaborator

@hossam-nasr: once this PR is ready for a re-review, please request another review from me through the UI. Thanks!

rename property name

fix tests

fix typo

don't change public types

simplify check

add clarifying comment

simplify callhttptask

avoid exporting moment types
add more unit tests

fix and update unit tests
fix tests

avoid moment

add header unit tests
@hossam-nasr hossam-nasr force-pushed the hossamnasr/callhttp-polling branch from dea8c4d to 022988f Compare May 20, 2022 20:45
@hossam-nasr hossam-nasr requested a review from davidmrdavid May 20, 2022 20:48
@hossam-nasr
Copy link
Contributor Author

hossam-nasr commented May 20, 2022

I think this PR is ready for another review now. After discussing with @davidmrdavid, these were the decisions that we made that I updated this PR with:

  • Header case-insensitivity: I missed a line in the extension code, which actually did make headers case-insensitive. I've updated this PR to also make the SDK treat headers case-insensitively.
  • Polling is now enabled by default. Even if this is considered a breaking change, it's still fine because the next version of the SDK will be a major version, so it's best to err on the side of enabling functionality that should be enabled.
  • The Schema V3 guard stayed in place. Even if we technically could still enable polling by specifying a default value for defaultHttpAsyncRequestSleepTimeMilliseconds if one is not provided by the extension, it's better to have the guard to encourage users to use the latest version of the extension.
  • I've also added unit tests

Copy link
Collaborator

@davidmrdavid davidmrdavid left a comment

Choose a reason for hiding this comment

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

tiny optimization. Other than that - 🚢 it.

src/durablehttpresponse.ts Outdated Show resolved Hide resolved
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.

callHttp does no polling
2 participants