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

Moves content layer sync to a queue and support selective sync #11767

Merged
merged 8 commits into from
Aug 29, 2024

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Aug 19, 2024

Changes

Currently if a sync call is made while the content layer is already syncing it is silently ignored. This PR refactors content layer syncing to instead use a queue for these calls. The motivation for this is to enable selective sync, and sync context. These are not publicly exposed yet, but in 5.0 will be available to integrations.

Testing

Tests still pass. Extra tests will be added once the feature is implemented.

Docs

Internal change

Copy link

changeset-bot bot commented Aug 19, 2024

🦋 Changeset detected

Latest commit: 3b9ff82

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Aug 19, 2024
@@ -152,6 +152,7 @@
"esbuild": "^0.21.5",
"estree-walker": "^3.0.3",
"fast-glob": "^3.3.2",
"fastq": "^1.17.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already a transitive dependency via about a million of our deps

@ascorbic ascorbic force-pushed the feat/refresh-content branch 2 times, most recently from c220faf to bb617b9 Compare August 29, 2024 10:16
@ascorbic ascorbic changed the title wip: allow integrations to refresh content layer Moves content layer sync to a queue and support selective sync Aug 29, 2024
@ascorbic ascorbic marked this pull request as ready for review August 29, 2024 11:36
@matthewp
Copy link
Contributor

Missing a changeset.

if (
options?.loaders &&
(typeof collection.loader !== 'object' ||
!options.loaders.includes(collection.loader.name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand !options.loaders.includes(collection.loader.name), but I ask just in case: why do we add this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this will allow selective sync: if loaders is passed then only loaders named in that list will be refreshed

*/

sync(options: RefreshContentOptions = {}): Promise<void> {
return this.#queue.push(options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pardon the question, I don't know how fastq works, and the the docs are a bit difficult to grasp. Does push execute the task by itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, pushing it onto the queue will start the queue running

@ascorbic ascorbic merged commit d1bd1a1 into main Aug 29, 2024
14 checks passed
@ascorbic ascorbic deleted the feat/refresh-content branch August 29, 2024 14:22
This was referenced Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants