Kresil is a Kotlin Multiplatform library for fault-tolerance, inspired by Resilience4j for Java and Polly for .NET. The library offers methods to enhance operations with resilience mechanisms in a functional style, using higher-order functions (decorators) while providing a concise API. Additionally, Kresil offers extensions for Ktor as plugins.
Some of the intended resilience mechanisms are:
- 🔄 Retry: Repeats failed executions;
- ⛔ Circuit Breaker: Temporarily blocks possible failures;
- ⏳ Rate Limiter: Limits executions per period;
- ⏱️ Time Limiter: Limits duration of execution;
- 🚧 Bulkhead: Limits concurrent executions;
- 💾 Cache: Memorizes a successful result;
- 🛟 Fallback: Defines an alternative value to be returned or action to be executed on failure.
The resilience mechanisms can be divided in two categories, based on where they execute:
- ⚡Reactive: Mitigates impact from failures (after);
- 🛡️Proactive: Prevents failures from happening (before).