feat: add the ability to build policies from a map with a :type#2
feat: add the ability to build policies from a map with a :type#2
Conversation
Summary of ChangesHello @k13gomez, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the flexibility and configurability of Failsage by introducing data-driven policy definitions. Users can now define resilience policies using simple Clojure maps, making it easier to manage policies from external configuration sources. This change streamlines policy creation and composition, supporting all existing policy types and integrating smoothly with current execution mechanisms, while maintaining API stability through internal refactoring. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is an excellent pull request that introduces a valuable feature for defining policies from data maps. The implementation is clean, the refactoring of policy logic into failsage.impl improves code organization, and the use of potemkin/import-vars correctly maintains API compatibility. The new policies function is a thoughtful addition for creating reusable policy lists. The documentation and tests are comprehensive and of high quality. I've identified two minor areas for improvement: one to clarify a docstring and another to make the map-based policy building more robust and idiomatic. Overall, great work.
58507ee to
d3e0b91
Compare
d3e0b91 to
c546895
Compare
This PR introduces map-based policy building, allowing policies to be defined using plain Clojure maps with a :type key (e.g., {:type :retry :max-retries 3}). All six policy types
(:retry, :circuit-breaker, :fallback, :timeout, :rate-limiter, :bulkhead)are supported and can be used directly withexecute,execute-async, andexecutorfunctions. This enables configuration-driven setups where policies can be loaded from config files, environment variables, or other data sources.Additionally, a new
policiesfunction is provided for explicitly creating reusable policy lists from regular policies, map-based policies, or mixed combinations. The implementation moves policy logic to failsage.impl (maintaining API compatibility via potemkin/import-vars) and extends the IPolicyBuilder protocol to support the Map interface. Comprehensive tests, documentation, and examples have been added for both features.