-
-
Notifications
You must be signed in to change notification settings - Fork 1
Lazily make connection with the underlying adapter #9
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
Open
thetutlage
wants to merge
8
commits into
0.x
Choose a base branch
from
feat/lazy-start
base: 0.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f9a2eaa
refactor: start queue in all environments except the console environm…
thetutlage 53bd21c
fix: acquire redis and database connections lazily from the drivers
thetutlage 152e250
Potential fix for pull request finding 'CodeQL / Workflow does not co…
thetutlage fe66aad
Merge branch '0.x' into feat/lazy-start
thetutlage 5105f99
chore: update dependencies
thetutlage a3fe078
fix: do not load jobs when warming up the app
thetutlage fd2822f
fix: remove the leftovers of the 0.x merge
thetutlage c02aa35
chore: update dependencies
thetutlage 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| name: "Close stale issues and PRs" | ||
| name: 'Close stale issues and PRs' | ||
| on: | ||
| schedule: | ||
| - cron: "30 0 * * *" | ||
| - cron: '30 0 * * *' | ||
|
|
||
| jobs: | ||
| stale: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/stale@v9 | ||
| with: | ||
| stale-issue-message: "This issue has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still need help on this issue" | ||
| stale-pr-message: "This pull request has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still intend to submit this pull request" | ||
| close-issue-message: "This issue has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still need help on this issue" | ||
| close-pr-message: "This pull request has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still intend to submit this pull request" | ||
| stale-issue-message: 'This issue has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still need help on this issue' | ||
| stale-pr-message: 'This pull request has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still intend to submit this pull request' | ||
| close-issue-message: 'This issue has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still need help on this issue' | ||
| close-pr-message: 'This pull request has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still intend to submit this pull request' | ||
| days-before-stale: 21 | ||
| days-before-close: 5 |
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,119 @@ | ||
| /* | ||
| * @adonisjs/queue | ||
| * | ||
| * (c) AdonisJS | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| import { test } from '@japa/runner' | ||
|
|
||
| import { defineConfig, drivers } from '../../index.js' | ||
| import { resolveAdapters } from '../../src/utils.js' | ||
| import { getDatabaseConfig, setupApp } from '../helpers.js' | ||
| import type { QueueConfig } from '../../src/types/main.js' | ||
|
|
||
| const databaseProvider = () => import('@adonisjs/lucid/database_provider') | ||
|
|
||
| test.group('drivers | database', () => { | ||
| test('do not acquire a connection when resolving the adapter', async ({ assert }) => { | ||
| const app = await setupApp( | ||
| 'console', | ||
| { | ||
| database: getDatabaseConfig(), | ||
| queue: defineConfig({ | ||
| default: 'database', | ||
| adapters: { | ||
| database: drivers.database({ connectionName: 'jobs' }), | ||
| }, | ||
| }), | ||
| }, | ||
| [databaseProvider] | ||
| ) | ||
|
|
||
| const db = await app.container.make('lucid.db') | ||
| const config = app.config.get<QueueConfig>('queue') | ||
| const resolvedAdapters = await resolveAdapters(config, app) | ||
|
|
||
| assert.isFunction(resolvedAdapters.database) | ||
| assert.isFalse(db.manager.isConnected('jobs')) | ||
| assert.isFalse(db.manager.isConnected('main')) | ||
| }) | ||
|
|
||
| test('acquire the configured connection when creating the adapter', async ({ assert }) => { | ||
| const app = await setupApp( | ||
| 'console', | ||
| { | ||
| database: getDatabaseConfig(), | ||
| queue: defineConfig({ | ||
| default: 'database', | ||
| adapters: { | ||
| database: drivers.database({ connectionName: 'jobs' }), | ||
| }, | ||
| }), | ||
| }, | ||
| [databaseProvider] | ||
| ) | ||
|
|
||
| const db = await app.container.make('lucid.db') | ||
| const config = app.config.get<QueueConfig>('queue') | ||
| const resolvedAdapters = await resolveAdapters(config, app) | ||
|
|
||
| resolvedAdapters.database() | ||
| assert.isTrue(db.manager.isConnected('jobs')) | ||
| assert.isFalse(db.manager.isConnected('main')) | ||
| }) | ||
|
|
||
| test('use the primary connection when no connection name is configured', async ({ assert }) => { | ||
| const app = await setupApp( | ||
| 'console', | ||
| { | ||
| database: getDatabaseConfig(), | ||
| queue: defineConfig({ | ||
| default: 'database', | ||
| adapters: { | ||
| database: drivers.database(), | ||
| }, | ||
| }), | ||
| }, | ||
| [databaseProvider] | ||
| ) | ||
|
|
||
| const db = await app.container.make('lucid.db') | ||
| const config = app.config.get<QueueConfig>('queue') | ||
| const resolvedAdapters = await resolveAdapters(config, app) | ||
|
|
||
| resolvedAdapters.database() | ||
| assert.isTrue(db.manager.isConnected('main')) | ||
| assert.isFalse(db.manager.isConnected('jobs')) | ||
| }) | ||
|
|
||
| test('do not acquire a connection when the app starts', async ({ assert }) => { | ||
| const app = await setupApp( | ||
| 'web', | ||
| { | ||
| database: getDatabaseConfig(), | ||
| queue: defineConfig({ | ||
| default: 'database', | ||
| adapters: { | ||
| database: drivers.database(), | ||
| }, | ||
| }), | ||
| }, | ||
| [databaseProvider] | ||
| ) | ||
|
|
||
| /** | ||
| * Starting the app in the "web" environment initializes the queue | ||
| * manager from the provider's start hook. Doing so must not open any | ||
| * connection, since nothing releases them in a process that never | ||
| * becomes ready (for example, the "codegen" command) | ||
| */ | ||
| await app.start(() => {}) | ||
|
|
||
| const db = await app.container.make('lucid.db') | ||
| assert.isFalse(db.manager.isConnected('main')) | ||
| assert.isFalse(db.manager.isConnected('jobs')) | ||
| }) | ||
| }) |
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.
Uh oh!
There was an error while loading. Please reload this page.