replicate / replicate-swift

Swift client for Replicate
https://replicate.com
Apache License 2.0
157 stars 33 forks source link

Add automatic retry policy #46

Open mattt opened 1 year ago

mattt commented 1 year ago

This PR refactors the client's internal fetch method to automatically retry requests as appropriate (429 status code, as well as 5xx errors for GET requests). If the server sends a Retry-After header, that value is used. Otherwise, the function delays for a configured interval with exponential backoff and jitter.

This should all be in line with the retry logic in the Python client.

mattt commented 1 year ago

Blocked by test cases not supporting different responses.