-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
fix: move application logic to service #3846
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
|
||
const env = feature.environments.find((e) => e.name === environment); | ||
const hasOnlyDisabledStrategies = env!.strategies.every( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the ! to ignore type system in production code is not a good idea. I replaced it with env?. because I managed to get null pointer here
{ environment, projectId, featureName }, | ||
userName, | ||
req.user, | ||
const updatedStrategy = await this.startTransaction(async (tx) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updating strategy and toggle should be part of one DB transaction
@@ -510,6 +510,29 @@ class FeatureToggleService { | |||
return this.unprotectedUpdateStrategy(id, updates, context, userName); | |||
} | |||
|
|||
async optionallyDisableFeature( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was previously in a controller but it means that change requests calling service methods don't have access to full functionality. Overall controller shouldn't orchestrate application logic, application service should do it.
@@ -180,7 +183,7 @@ const createTestSegments = async () => { | |||
|
|||
beforeAll(async () => { | |||
db = await dbInit('segments', getLogger); | |||
app = await setupApp(db.stores); | |||
app = await setupAppWithCustomConfig(db.stores, {}, db.rawDatabase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to pass raw database because otherwise transactions don't work in this test
); | ||
} | ||
} | ||
|
||
async unprotectedUpdateStrategy( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is called by change requests apply method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
About the changes
Fixing problem that manifested in change requests application but the root cause was in the toggle controller:
Important files
Discussion points