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

feat: allow partial subjects #18

Merged
merged 2 commits into from
Apr 13, 2024
Merged

feat: allow partial subjects #18

merged 2 commits into from
Apr 13, 2024

Conversation

lanej
Copy link
Member

@lanej lanej commented Apr 13, 2024

Throw Feature::Subject::NotApplicable when an invalid subject is specified. This allows for better differentiation of error cases.

Given a feature specified as:

user:
  id: 1

and a feature check like Feature.enabled?(:check, user_id: 1) then when the feature was modified to include additional constraints like

user:
  id: 1
age:
  gt: 3

every caller would immediately fail with Feature::Subject::Invalid. In production this creates an intensely tight coupling between the caller and feature data source that is effectively impossible to safely modify.

By allowing partial subject checks the coupling is removed, allowing for data source additions without active caller errors.

If a subject is specified by the caller but removed from the data source, an error is still created.

- Throw `Feature::Subject::NotApplicable` when an invalid subject is
  specified.  This allows for better differentiation of error cases.

Given a feature specified as:

```yaml
user:
  id: 1
```

and a feature check like `Feature.enabled?(:check, user_id: 1)` then
when the feature was modified to include *additional* constraints like

```yaml
user:
  id: 1
age:
  gt: 3
```

every caller would immediately fail with `Feature::Subject::Invalid`.
In production this creates an intensely tight coupling between the
caller and feature data source that is effectively impossible to safely
modify.

By allowing *partial subject checks* the coupling is removed, allowing
for data source additions without active caller errors.
@lanej lanej requested a review from a team April 13, 2024 17:54
@lanej lanej merged commit d66963a into master Apr 13, 2024
3 checks passed
@nwithan8 nwithan8 deleted the partial-subject branch April 13, 2024 18:17
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.

2 participants