Repository navigation
Add Blog sample types and a seeder API - #2772
Merged
Merged
Conversation
ISeeder, SeedContext and ISeedRunner in the SDK; cms.Seeding in core runs registered seeders on start as the system principal with the Seed origin. samples/Blog holds the sample types, typed settings and an idempotent seed set with a translation, a trashed and a scheduled article.
The seeding settings area keeps each seeder's applied version and a claim taken with a compare-and-swap write, so boots skip applied seeds and concurrent boots run one. Entries are found by slug, each step converges, and the locale insert tolerates a concurrent boot and writes activity.
…ing edits The claim has an id and is renewed while the run lasts; only a stale claim is taken over, and a run releases or finishes only its own. Seeders get the version they were last applied at, and the Blog seed changes state only for what it created or on a first run.
Any exception after the claim is taken releases it if it is still the run's, and the Blog seed's state steps accept an entry that an overlapping run or a person already published, trashed or purged.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2706.
What
FluentCMS.Seeding:ISeeder,SeedContext(services, site, locale, the host clock,InLocale) andISeedRunner.cms.Seeding.Add<T>(),RequireLocale(...),RunOnStartandClaimTimeout. Seeders run inStartAsyncafter the migrations, on the default site, as the system principal with theSeedorigin. With no seeder added nothing is added to start-up. Only seeders added withAddrun, at boot and throughISeedRunner.NameandVersion) and a claim are kept in the instance settings areaseeding(no system table). A run claims the seeder with a write that names the version it read; an instance that loses skips and boots normally, and a claim older than 15 minutes can be taken over.SiteManager.EnsureLocaleAsyncadds a locale to the default site if missing. Site management arrives in M2, and the sample needsfr.samples/Blog:Article,Author,Tag,Seo,HeroBlock,QuoteBlock,GalleryBlock, typedBlogSettings([Settings("blog")]),BlogSeederandcms.AddBlogSample().DeleteAsync, scheduled last withScheduleAsync30 days after the host clock) and the site's blog settings. Everything goes through the public services.Decisions
Authorgained a unique slug), each step converges (publish if draft, add fr if missing, trash if not trashed, schedule if still a draft), a unique conflict counts as already there, and purged or renamed content does not come back because an applied seeder is skipped.SiteSettingsis typed settings, not the singleton from 4.2, as the notes on the issue say.GalleryBlockhas a caption and a column count for now.samples/Blogreferences Sdk and Core, to offerAddBlogSample. No system table or migration change.Tests
BlogSampleTestsandBlogSeedingTestsinFluentCMS.Core.IntegrationTests(the second covers concurrent runs on a file database, purge, rename and settings change then another boot, a crash halfway then a rerun, a version bump, claim timeout, failure release) (one seeded host for the class, about 0.5 s): types register, read-back of authors, tags, articles, relations, blocks and component, the fr translation, the trashed entry only in the trash, the scheduled entry a draft withSchedulePublishAtat clock plus delay, Seed origin in the versions, settings stored, a second run creates no rows, and a host without the sample has no seed service.dotnet build -c Release -warnaserrorand the fulldotnet test -c Release(2779 tests) pass locally. Markdown lint is clean. SQLite only; PostgreSQL and SQL Server follow #2711.No new packages.