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

Durability is broken for subsequent generator iterations after the first #31

Closed
Bilge opened this issue Mar 15, 2017 · 2 comments
Closed
Labels
Milestone

Comments

@Bilge
Copy link
Member

Bilge commented Mar 15, 2017

Durability is provided for the $provider->fetch call, but Provider::fetch is declared to return Iterator, which is typically implemented using generators. Generators imply deferred code executions, which means that even if the generator throws an exception, it is not caught by the retry handler because it already exited that code block.

This common case is not captured by PorterTest because it only tests that Provider::fetch throws an exception directly instead of the generator throwing an exception.

@Bilge Bilge added the bug label Mar 15, 2017
@Bilge Bilge added this to Confirmed in TODO Mar 16, 2017
@Bilge
Copy link
Member Author

Bilge commented Mar 16, 2017

Workaround available since 17345ba. However, this is a crude stop-gap solution because it only supports the first iteration of the generator. Resources may reuse a connector on subsequent iterations: a typical case is seamless pagination where the subsequent page requests may fail but are still not covered by Porter's durability features.

To fully resolve this issue we need to provide durability features at the connector level as in v1, but unlike those versions we will not require connectors to duplicate durability code in each implementation. Porter will provide a factory which accepts a closure from the connector when it makes connections and provides preconfigured durability features for that connection. This feature will target Porter v4.

@Bilge Bilge changed the title Durability is broken for generators Durability is broken for subsequent generator iterations after the first Mar 16, 2017
@Bilge Bilge added this to the 4.0.0 milestone Jun 21, 2017
@Bilge Bilge moved this from Confirmed to In development in TODO Mar 30, 2018
@Bilge
Copy link
Member Author

Bilge commented Apr 3, 2018

Solved with ConnectionContext::retry introduced in #46 🏷️ 4.0.0. Connector implementations are expected to wrap their fetch code in a closure passed to this retry() method.

@Bilge Bilge closed this as completed Apr 3, 2018
@Bilge Bilge removed this from In development in TODO Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant