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

[enhancement request] make retryer and sleeper more flexible #121

Open
yanshenxian opened this issue Jul 6, 2020 · 5 comments
Open

[enhancement request] make retryer and sleeper more flexible #121

yanshenxian opened this issue Jul 6, 2020 · 5 comments

Comments

@yanshenxian
Copy link

yanshenxian commented Jul 6, 2020

sdk version: 4.0.0

B2StorageClient client = B2StorageClientFactory
             .createDefaultFactory()
             .create(APP_KEY_ID, APP_KEY, USER_AGENT);

The default B2RetryPolicy wil try max 8 attempts and each time wil sleep at least 1 second.

Because hard code sleeper.sleepSeconds(waitSeconds) written at com.backblaze.b2.client.B2Retryer#doRetry(java.lang.String, com.backblaze.b2.client.B2AccountAuthorizationCache, com.backblaze.b2.client.B2Retryer.RetryableCallable<T>, com.backblaze.b2.client.B2RetryPolicy)

And these classes (and some parameter classes) are package accessed.

It's not easy to change the retry behavior... 😢

@certainmagic
Copy link
Contributor

Hi yanshenxian --

It's true, the B2StorageClientFactory doesn't make it easy to change the retry policy. Sorry. The B2StorageClientFactory is fairly new and doesn't expose all of the flexibility of the rest of the SDK.

To set the B2RetryPolicy implementation to your own class with the existing code, you will need to use something like the B2StorageHttpClientBuilder and call setRetryPolicySupplier, passing a Supplier.

Alternatively, if you would like to make a PR that adds setRetryPolicy() to B2StorageClientFactory, I'd be open to reviewing it. :)

thanks,
ab

@certainmagic
Copy link
Contributor

Hi yanshenxian --

Were those pointers helpful?

thanks,
ab

@yanshenxian
Copy link
Author

@certainmagic hi thanks for your reply~
I'm using setRetryPolicy() simply now. But sorry for have not enough time to write a functional pr...

@certainmagic
Copy link
Contributor

hi yanshenxian --

It looks like your reply got truncated somewhere along the way.

ttfn,
ab

@certainmagic
Copy link
Contributor

Hi @yanshenxian --

Just checking in...

ttfn,
ab

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

No branches or pull requests

2 participants