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

Struggling to understand wrapping concept for WaitAndRetry, Circuit Breaker and Fallback alltogether #1139

Closed
nikriaz opened this issue Apr 17, 2023 · 2 comments
Labels
stale Stale issues or pull requests

Comments

@nikriaz
Copy link

nikriaz commented Apr 17, 2023

I’m struggling to understand wrapping concept for WaitAndRetry (WR), Circuit Breaker(CB) and Fallback (FB) policies all together. Specifically, I’m referring to the table “Ordering the available policy-types in a wrap” in the Wiki Can someone please clarify?

  1. Scenario 1. WR wraps CB. Wiki suggests to have CB’s break time shorter then waiting time in WR. In this case, CB will able to open and close between tries. So, what is the meaning of the circuit breaker then, if no calls to its open state, i.e., able to “use” its open state? If in this scenario break time is longer than WR’s waiting time, then it’s simply equal to lesser number of retries because it seems retries to the open state will be immediately thrown, so no reason to plan such “hopeless” retries in advance.
    I can’t understand reasoning of such scenario at all.

  2. Scenario 2. CB wraps WR. I’m struggling to understand how fails are counted for CB in this scenario. If all retries of WR are counted, does it mean that number of fails for CB should be exactly equal to WR’s number of retries? Otherwise, if CB’s config number of fails less than WR’s retries, then WR has no chance to execute all retries. If CB fails greater than WR retries, than CB has no chance to switch to the open state, because CB does not trigger retries. Or, maybe CB counts fails of WR itself (when all retries are over)? Meaning, if CB fails = 5 and WR = 5, we need to have 5 external calls, to have make total 5*5=25 calls to the world, to switch CB to open state?

Furthermore, it’s unclear how to wrap Fallback policy then. Wiki says it “Can also be used mid-wrap ... eg as a failover strategy”. This is my case,

Let’s say we have Policy.Wrap(CB, FB, WR) and for CB number of fails = 5 and WR retries = 5. Then, on the fifth retry CB will be opened, then seems no chance for FB to execute. If the CB = 7 and WR = 5, then who will make retry to execute FB? For me it looks like if the number of fails for CB should be exactly equal to WR’s number of retries, then there is no room for FB.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2023

This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.

@github-actions github-actions bot added the stale Stale issues or pull requests label Jul 1, 2023
@github-actions
Copy link
Contributor

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues or pull requests
Projects
None yet
Development

No branches or pull requests

1 participant