Closed piotr-yuxuan closed 2 years ago
Thanks @piotr-yuxuan!
I wrote the initial impl of True Grit ~3 years ago, and I don't recall seeing safely
at the time, though it would have been around. I just remember not liking the alternatives I did find, but we had to do something because Netflix was sunsetting Hystrix, so I wrote my own. I love Bonacci's mulog library and its ideas, however, so I'm open to suggestions. What do you want to see?
I looked over safely
for ideas, and if you're currently using it, I can see a few things you might want to be aware of:
safely
CB state is keyed off more than a name/keyword, which is mildly suboptimal, because it means you can't share a circuit breaker across multiple fns. This is useful when you have multiple fns hitting the same underlying service (e.g., if fns get-flaky-service
and put-flaky-service
want to share what they both know about trying to use "flaky-service")safely
macro doesn't default to bound-fn
or any other thread frame copying method, which will cause surprise problems with fns like binding
(though people should really avoid thread-specific binding anyway)). OTOH safely
does some things I wish True Grit did:
robustify
) because the original syntax was kind of awkward. But I do worry about people shooting themselves in the foot.That being said, I think True Grit is more composable, extensive, and simpler, but hey, I'm biased. 😄
Hmmm, I just thought of a slight addendum in regards to saying "It looks like safely
CB state is keyed off more than a name/keyword". Since it keys off all the options, you should be able to share the same CB between multiple fns if all the options are the same, including the CB name. But, that means they all have to have the same retry/timeout/etc policy, which you may not want to share.
Anyway, @piotr-yuxuan did you see my Slack messages about primitive-math and byte-streams PRs?
Hello, thank you for this great little project! I wonder if you've come across safely [0] and whether you could find there ideas to port to TrueGrit? :-)
[0] https://github.com/BrunoBonacci/safely