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

Use rescue to avoid dependency inversion #744

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

carrascoacd
Copy link
Contributor

@carrascoacd carrascoacd commented Jan 13, 2025

Problem

When using Finch is expected to receive a RuntimeError if the connection pool is exhausted, see https://github.com/sneako/finch/blob/main/test/finch_test.exs#L561

This is a problem because in a service that uses a lower tier API than the service itself, a dependency inversion of tiers can happen. For example, a tier 2 service calling a tier 3 service.

The tier inversion happens because we are not rescuing the error and returning it into a tuple, so the operation can work without problems under this situation.

Proposed solution

Encapsulate the error in the error tuple. I'm adding this solution here, but I want to know if you consider that it would be best suited in the Finch code itself. Changing reraise basically.

cc/ @yordis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant