-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat(trigger): add trigger-eu-region flag to switch runs to eu-central-1 #5173
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const { mockIsFeatureEnabled } = vi.hoisted(() => ({ | ||
| mockIsFeatureEnabled: vi.fn(), | ||
| })) | ||
|
|
||
| vi.mock('@/lib/core/config/feature-flags', () => ({ | ||
| isFeatureEnabled: mockIsFeatureEnabled, | ||
| })) | ||
|
|
||
| import { | ||
| resolveTriggerRegion, | ||
| TRIGGER_REGION_EU_CENTRAL, | ||
| TRIGGER_REGION_US_EAST, | ||
| } from '@/lib/core/async-jobs/region' | ||
|
|
||
| describe('resolveTriggerRegion', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks() | ||
| }) | ||
|
|
||
| it('returns eu-central-1 when the flag is enabled', async () => { | ||
| mockIsFeatureEnabled.mockResolvedValue(true) | ||
| expect(await resolveTriggerRegion()).toBe(TRIGGER_REGION_EU_CENTRAL) | ||
| expect(mockIsFeatureEnabled).toHaveBeenCalledWith('trigger-eu-region') | ||
| }) | ||
|
|
||
| it('returns us-east-1 when the flag is disabled', async () => { | ||
| mockIsFeatureEnabled.mockResolvedValue(false) | ||
| expect(await resolveTriggerRegion()).toBe(TRIGGER_REGION_US_EAST) | ||
| }) | ||
|
|
||
| it('evaluates globally, passing no gating context', async () => { | ||
| mockIsFeatureEnabled.mockResolvedValue(false) | ||
| await resolveTriggerRegion() | ||
| expect(mockIsFeatureEnabled).toHaveBeenCalledTimes(1) | ||
| expect(mockIsFeatureEnabled.mock.calls[0]).toEqual(['trigger-eu-region']) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { isFeatureEnabled } from '@/lib/core/config/feature-flags' | ||
|
|
||
| /** Default Trigger.dev region — the project default when the eu-central flag is off. */ | ||
| export const TRIGGER_REGION_US_EAST = 'us-east-1' | ||
|
|
||
| /** Target region when the `trigger-eu-region` flag is enabled. */ | ||
| export const TRIGGER_REGION_EU_CENTRAL = 'eu-central-1' | ||
|
|
||
| /** | ||
| * Resolve which Trigger.dev region a run should execute in. Gated globally by the | ||
| * `trigger-eu-region` feature flag (all-or-nothing — no per-user/org targeting): | ||
| * `eu-central-1` when enabled, otherwise `us-east-1`. | ||
| * | ||
| * The result is passed as the `region` option to `tasks.trigger` / `batchTrigger`, | ||
| * overriding the project's dashboard default per run. | ||
| */ | ||
| export async function resolveTriggerRegion(): Promise<string> { | ||
| return (await isFeatureEnabled('trigger-eu-region')) | ||
| ? TRIGGER_REGION_EU_CENTRAL | ||
| : TRIGGER_REGION_US_EAST | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Promise<string>is wider than the two values this function can actually return. Narrowing it to the union of the two exported constants lets TypeScript catch any future drift between the constants and the implementation, and gives callers a precise type to exhaustively switch on.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!