Plugable wait function and retry predicate

I want to use this for aws, where the heuristics in the built-in shouldRetry function don't apply.

To make this useful for more cases, I broke out the method that checks if the request can be retried, and added an optional wait function.