Repository navigation
Conversation
…range keys - add AdoptTable: convert an existing plain table into a partitioned one once, transactionally, keeping the original as a backup (WithConversionBackup(Drop) removes it after the row-count check) - support timestamptz/timestamp/date range keys (RangeKeyType), detected from the declared column with WithRangeKey(...) as an override; the cache still stores from_date/to_date as Unix seconds - guard adopted tables: missing/foreign partitioned tables are rejected, incoming foreign keys and dependent views block the conversion - reset identity sequences, verify row counts, cap conversion partitions - register the adopter in keyed and keyless modules - tests, documentation and version bump to 0.18.0
…ionable - validate schema and root-table names at Build, not only the cache table - partition-name error now reports root/separator/value/suffix bytes, the excess over 63 and the available levers (WithPartSeparator, shorter names/values, WithPartTablePostfix for the cache table) - document the 63-byte practices and keep hash-based naming out of the default path
…tion names - WithLongPartitionName(Func<PartitionNameContext, string>) is invoked only when the regular partition name exceeds PostgreSQL's 63-byte limit - the context exposes root, separator, values, range suffix, default flag, ideal name and byte size - the replacement must be a bare name of at most 63 bytes; empty/oversized results fail with an actionable error - callback covers intermediate list levels and DEFAULT partitions; the cache table keeps its own postfix and the root name is still validated at Build - tests and documentation
…t workflow
SDD layer (SPEC-000)
- add specs/, templates/, checklists/ at the repo root and group docs into
docs/{architecture,development,decisions,repository}; link the workflow from both READMEs
- record the verified baseline at 2b422c9: build 0 warnings/0 errors, tests
2712/2711 passed/1 skipped, 16 packages, plus the path-dependent reference inventory
Layout move (SPEC-001)
- move all 17 library projects (src/Sa, src/Sa.*) to src/Libraries/<Name>/
- update every path-dependent reference: props imports, packed NuGet.md/icon,
Sa.slnx (single /Libraries/ solution folder), samples/tests/benchmarks project
references, build-sh/tasks.sh, build/tasks.ps1, package-check.sh, CI, .gitignore
- no source, version, TFM, package-ID or public-API change
Build tooling fixes (SPEC-002)
- clean() now runs `dotnet clean` before build instead of a second `dotnet build`
- do-push-local.sh pushes to src/nupkgs; do-push-prod.sh requires NUGET_API_KEY
- nu_push fails when dist/ is empty; do-fix-max-path-linux.sh derives the repo root
- fix build-sh/tools/secrets.cs and build-sh/readme.md pre-move paths
Verified: build 0/0, tests 2712/2711/1/0, 16 nupkg + 16 snupkg, package check green.
SPEC-003. Split the flat src/Libraries/ list into domain folders while
keeping package identity, public API and TFMs untouched:
Configuration/ Sa.Configuration, Sa.Configuration.PostgreSql
Data/ Sa.Data.PostgreSql, Sa.Data.S3, Sa.Data.TempFolder
Hybrid/ Sa.HybridFileStorage{,.FileSystem,.Postgres,.S3}
Media/ Sa.Media, Sa.Media.FFmpeg
Outbox/ Sa.Outbox, Sa.Outbox.PostgreSql
Sa, Sa.Partitional.PostgreSql, Sa.Schedule and Sa.Utils.WorkQueue stay
directly under src/Libraries/.
- rewrite every relative reference one level deeper (props imports,
ProjectReference, Compile Include) across libraries, samples, tests,
benchmarks and fixtures
- Sa.slnx: grouped paths + flat /Libraries/<Group>/ solution folders
(nested <Folder> elements are silently ignored by the SDK)
- Common.NuGet.Properties.xml: resolve packed NuGet.md/icon.png from
$(MSBuildThisFileDirectory) so depth no longer matters
- packaging is group-agnostic: nu_pack()/NuPack locate <Project>.csproj
under src/Libraries/ instead of hard-coding the project folder
- update package-check.sh, CI line-ending path, .gitignore, build-sh
readme and the live docs
Verified: build 0 warnings/0 errors (48 projects), tests 2712 total /
2711 passed / 1 skipped / 0 failed, 16 nupkg + 16 snupkg at unchanged
versions, package check green, 0 unresolved project references.
Move Sa.Partitional.PostgreSql, Sa.Schedule and Sa.Utils.WorkQueue from src/Libraries/ into the new Misc/ group folder. - git mv the three standalone projects into src/Libraries/Misc/ - rewrite path-dependent references (props import depth, shared-source links, cross-group ProjectReferences, samples/tests/benchmarks refs) - add /Libraries/Misc/ solution folder in src/Sa.slnx - update live docs and add specs/004-libraries-misc (SPEC-004) Verification: build 0/0 (48 projects), scripted reference resolution unresolved 0, markdown link check broken 0, full test run green (failed 0, skipped 1), affected unit suites green.
msg_seq is allocated by nextval at COPY time, but a row only becomes visible at COMMIT. Two publishers of the same (tenant, part) could therefore interleave as "A takes the lower seqs and commits last", and the consumer - whose cursor is max(msg_seq) - would advance past A's rows and never deliver them. Measured before the fix on 8 parallel publishers (batch 1024, caught-up consumer polling every 20 ms): 1.2-7 % of all rows lost, scaling with batch x writers. Zero loss when the consumer lags behind the head, which is why it went unnoticed. Fix: take pg_advisory_xact_lock per (tenant, part) inside the publish transaction, so the sequence is only handed out under the lock and seq order equals commit order within a part. The two-int lock form uses its own namespace, so it cannot collide with the cursor lock. Keys are sorted inside a MATERIALIZED CTE to rule out deadlocks between publishers sharing several parts. The non-transaction path now wraps the COPY in an explicit transaction (a xact lock taken by a separate statement would be released before the COPY) and disposes the binary importer before COMMIT. Cost: serializing a part also serializes its commits, so group commit stops amortizing fsync. 8 producers into one part: 14.8k rows/s against 55.3k without the lock; with one producer per part the cost is zero (43.7k rows/s, p50 32 ms against 23.5k/77 ms over three parts). Also: - index (msg_seq) on __msg$: the cursor read was a Seq Scan of every daily leaf inside the lookback window, 56.8 ms / 10 377 buffers against 0.166 ms / 14. Declared on the root, so existing and future partitions inherit it. - OutboxDefaults.MaxBatchSize 16 -> 128 and OutboxPublishSettings.MaxBatchSize 64 -> 256: one poll/publish pays a fixed price (transaction, lock, fsync), measured 4.7k -> 58k rows/s across that range. - tests: PublishPartLockTests (second publisher waits, seq ranges do not interleave, different parts do not block), PgAdvisoryKeysTests, MsgCursorIndexTests (index on the root and on a partition created later). 176/176 Sa.Outbox.PostgreSqlTests, 137/137 Sa.Outbox.Tests. - readmes: corrected the message lifecycle (offset is a materialisation watermark, tasks are never deleted), added consumer groups and bulk publishing sections with the measurement tables, fixed the "under the hood" table.
…eptor - Sa.Outbox.Redis: stream + PEL delivery, XAUTOCLAIM/XPENDING, poison handler, retention via XTRIM MINID with a safe floor, Microsoft.Extensions.Options settings (WithConfiguration/Options) and bilingual docs/tests. - Sa.Outbox.PostgreSql: IPgOutboxPoisonHandler interceptor for permanent failures with Default (__error$) / Handled (skip __error$) strategies. - Central Sa.Outbox Readme: provider overview, shared guarantees and PostgreSQL/Redis differences. - Build: add StackExchange.Redis and the Redis project/tests to the solution.
…oviders Both providers carried their own IOutboxMessageSerializer, an internal reflection JSON default and their own WithDefaultSerializer registration, so the same wire format was configured twice, the two identical interfaces were ambiguous in a project referencing both packages, and a serializer could not be chosen once for the whole outbox. Move the strategy to the core: - Sa.Outbox.Serialization: IOutboxMessageSerializer, JsonOutboxMessageSerializer (UTF-8 JSON, same wire format as before) and OutboxPayloadCodec, the pooled byte bridge moved from the Redis provider. - AddSaOutbox registers the JSON serializer via TryAddSingleton, so any serializer registered earlier wins; new IOutboxBuilder.WithMessageSerializer overloads (factory / instance / type) set it once for every provider. - PostgreSQL and Redis resolve the core service and no longer ship a default. Their public interfaces remain as compatibility subtypes, and a serializer registered directly under the legacy type is bridged to the core service after the user delegate. Provider WithMessageSerializer now replaces the shared core registration (last call wins). - tests: fallback, earlier registration, all three builder overloads and the codec round-trip in Sa.Outbox.Tests; provider fallback, provider override, legacy implementation and legacy DI registration in both provider test projects. Sa.Outbox.Tests 143/143, Sa.Outbox.RedisTests 25/25 (end-to-end), PG composition and OutboxTests pass; solution builds warning-free. - readmes: a Serialization section in the core Readme (EN/RU), corrected provider and configuration docs (WithDefaultSerializer is gone, the fallback and compatibility bridge are documented), and the provider table now links both Outbox packages from the root README.
…contracts
PostgreSQL polling and configuration:
- opt-in provider-wide polling defaults (PgPollingSettings) with the
Quiet/Balanced/Responsive presets, a latency-budget form
(WithPollingBudget) and configuration-section binding
(WithPollingFromConfiguration)
- scalar PgOutboxSettings binding from configuration
(WithOutboxSettingsFromConfiguration / PgOutboxOptions)
- consumer-group section convention Outbox:DeliveryGroups:{group}
(IOutboxBuilder.WithDeliveryConfigurationSection; an explicit key wins,
an empty key opts the group out); configurationKey now also accepted by
the id-less AddDelivery overloads
- one-call registration AddSaOutboxUsingPostgreSql(cfg, outbox, scopeKey)
- fail-fast validation of the polling budget/profile at registration
Provider plug point (Sa.Outbox.PlugServices):
- AddOutboxProvider(descriptor, builder): provider identity, capability
flags and one-call registration of the three storage contracts;
replaces the commented-out IOutboxPlugin
- IOutboxProviderRegistry validates the installation (one provider, bulk
writer, delivery manager when consumer groups exist, detector when the
TenantDetection capability is declared) against registrations only,
without constructing provider services
- hosted validator fails the host start and logs the provider once
Contract simplification (breaking):
- IOutboxBulkWriter has one abstract batch overload; the legacy
per-message overloads and OutboxMessage<T> are removed
- OutboxDeliveryMessage<T> is a flat record with an explicit
OutboxRentToken (Key/SubKey), exposed as IOutboxContext.RentToken;
PostgreSQL fills (task, delivery), Redis (stream ms, seq)
- the publisher rejects a publish context unless the provider declares
PublishContext, before any write
- PostgreSQL legacy bulk-insert path and the dead duplicate
IOutboxContextFactory removed; Redis stops packing rent state into
OutboxId and acknowledges by token
- versions: Sa.Outbox 0.18.0, Sa.Outbox.PostgreSql 0.18.0,
Sa.Outbox.Redis 0.2.0
Tests: Sa.Outbox 162, Sa.Outbox.PostgreSql 242, Sa.Outbox.Redis 26.
…tgreSQL) Provider key plumbing: - OutboxConsumerSettings.ProviderKey and OutboxMessageFilter.ProviderKey carry the provider key (equal to the outbox scope key) through the delivery pipeline; FilterFactory and AddDeliveryJob fill it - IOutboxStorage routes delivery to the keyed IOutboxDeliveryManager, with an unkeyed fallback for the default provider Keyed contracts and publishing: - AddOutboxProvider(providerKey, descriptor, builder) registers the three storage contracts keyed; the default key keeps unkeyed aliases - factory overloads (WithBulkWriter(Func<...>) etc.) for providers whose implementations depend on keyed services - IOutboxMessagePublisher/OutboxPublishSettings are keyed per provider; IOutboxPublisherResolver.For(key) addresses them and the default key keeps an unkeyed publisher alias - keyed IOutboxProviderRegistry per provider plus the existing unkeyed alias for the default key; the hosted validator now validates and logs every registered provider key - consumer group ids must be unique across providers (validated when the manager is built); same-id groups within one provider stay tolerated PostgreSQL: - settings, component settings, polling settings, data source, SQL builder, commands, type resolver/cache, task loader, repositories, poison handler and the delivery-group options provider are keyed by the provider key; partitional lookups use the keyed settings - the unkeyed NpgsqlDataSource fallback is preserved for the default key (borrowed pool), and keyed data sources are resolved through PgDataSourceResolver - per-provider configure and polling actions are keyed, so two providers no longer overwrite each other Tests: Sa.Outbox 164, Sa.Outbox.PostgreSql 246 (including two PG providers with separate schemas, publishers and groups), Sa.Outbox.Redis 26. Slice 2 (keyed Redis) and slice 3 (composite group keys, per-provider health) remain.
Registration:
- AddSaOutboxUsingRedis(configure, configureOutbox, scopeKey): one-call
form; the scope key is the provider key. The classic (configure,
scopeKey) overload stays and delegates
- the three contracts register through AddOutboxProvider(key, ...) with
the factory overloads, so they resolve the provider's own keyed
services
Settings and connection:
- RedisOutboxSettings is per provider: named options whose name is the
key, keyed code actions and section state, keyed materialised settings
with an unkeyed alias for the default key
- the settings configurator is IConfigureNamedOptions: it applies the
provider's own actions and configuration section, and for a non-default
key whose prefix is still the default it appends ':{providerKey}', so
several providers on one Redis database never collide
- IDatabase, IRedisOutboxConnectionProvider and the connection options
are keyed; an application-registered unkeyed database is still
preferred, and the default key keeps the unkeyed aliases
Commands and poison handling:
- every command (publish, rent, finish, extend, group registry, trimmer)
is keyed and built from the provider's keyed database and settings
- the poison handler is keyed (WithPoisonHandler) with the unkeyed Drop
default; rent/finish prefer the keyed registration
Docs: PlugServices status (slices 1 and 2 done) and the Redis readmes'
multi-provider section.
Tests: Sa.Outbox.Redis 30 (two providers with prefixed settings, per-key
registries and group-to-provider binding), Sa.Outbox 164,
Sa.Outbox.PostgreSql 246. Slice 3 (composite group keys, per-provider
health) remains.
- OutboxProviderHealthReport / IOutboxProviderHealth / IOutboxHealth in the plug-services layer; the contract is transport-agnostic (no Microsoft.Extensions.Diagnostics.HealthChecks dependency in the core) - providers register IOutboxProviderHealth keyed: PostgreSQL runs SELECT 1 on its data source, Redis runs PING - IOutboxHealth is an unkeyed singleton that checks every registered provider key, stamps ProviderKey, measures latency, reports a missing check as healthy and turns a throwing check into an unhealthy report instead of failing the aggregate - docs: the health section and the slice-3 status in PlugServices Tests: Sa.Outbox 170 (6 new aggregate tests), Sa.Outbox.PostgreSql 247 (health over two providers), Sa.Outbox.Redis 31 (health over the fixture). Slice 3 part 2 (composite group keys) remains.
…ard (slice 3, part 2) Group identity: - OutboxGroupKey(providerKey, groupId); the consumer settings registry, the idle-state registry, the delivery job and the singleton consumer cache are keyed by it, so the same group id may exist under two providers - IOutboxConsumerManager gains OutboxGroupKey overloads for Apply/TryRegister/Get/Pause/Resume/IsPaused/IsRegistered/Unregister/ Subscribe (default interface implementations keep third-party implementations compiling); the string overloads keep working while the id is unambiguous and throw a named ambiguity error otherwise - IConsumer<T> is registered keyed by OutboxGroupKey, with a plain group-id alias for the default provider; DeliveryLifetimeInvoker resolves composite-first and falls back to the string key, so manual legacy registrations keep working - delivery jobs are registered with a factory carrying the composite key, and the idle-state registry is addressed by it (unique per provider) - GetAllConsumerGroupIds returns the distinct plain group ids, so partition names stay unchanged PostgreSQL migration safety: - PgMultiProviderGuard fails the host start when two providers point at the same tables (same database identity + schema + table names): both would consume the same rows and deliver every message twice - the PG readmes gain a 0.17 → 0.18 migration section: no schema change, the API checklist, adding a second provider, moving to a non-default key, rollback and the Redis prefix caveat Tests: Sa.Outbox 170 (composite manager identity), Sa.Outbox.PostgreSql 251 (4 layout-guard tests), Sa.Outbox.Redis 31.
- PgOutboxPublisherExtensions adds PublishInTransaction / PublishSingleInTransaction: the caller's NpgsqlTransaction is a typed parameter instead of the core's opaque object? context, so a wrong context cannot compile - the helpers are named InTransaction because an instance method shadows a same-named extension; the core interface keeps its object? overload for providers and exotic contexts - only NpgsqlTransaction is accepted: a PgTransaction is passed as sqlTx.Transaction. A second overload for the wrapper duplicated the whole matrix for no gain and would have made a null literal ambiguous - docs: the caller-transaction section of the PG readmes now shows the typed call and explains the naming; the PlugServices follow-ups record that the typed context shipped without a core major and that the opaque rent token is not being introduced (16-byte OutboxRentToken plus a provider-side table if more state is ever needed) Tests: Sa.Outbox.PostgreSql 254 (transaction tests cover the typed helpers on commit and rollback), Sa.Outbox 170, Sa.Outbox.Redis 31.
- new Sa.Outbox.MultiProviderTests (added to Sa.slnx): a PostgreSQL container and a Redis container behind one service provider — PG under "mixed-pg" with its own schema, Redis under "mixed-redis" with an explicit key prefix - proves the cross-provider case the per-provider suites cannot: the keyed publishers are distinct, publishing lands in the right storage (rows vs stream entries), IOutboxHealth reports both providers healthy, and every consumer group is bound to its provider key - docs: the PlugServices status now marks all three slices implemented (health and composite keys), the tests list covers the mixed-provider, layout-guard and composite-key cases, and the constraints no longer claim global consumer-group-id uniqueness - the Redis readmes gain a 0.1 → 0.2 migration section: no data migration, the default key keeps the old prefix, and moving to a custom key requires an explicit prefix to keep the existing streams Tests: Sa.Outbox.MultiProviderTests 3, Sa.Outbox 170, Sa.Outbox.PostgreSql 254, Sa.Outbox.Redis 31.
- RedisMultiProviderGuard fails the host start when two providers share the storage layout: the same endpoint(s), logical database index and key prefix/separator. Such providers append to and consume from the same streams, so every message would be delivered twice - the comparison uses the connection string and opens no connection; a provider fed by an explicit IDatabase/IConnectionMultiplexer factory or by a borrowed registered database is skipped, because its endpoint is unknown before the factory runs — a valid setup is never rejected - one unkeyed marker per provider key, one guard for all of them - docs: the PlugServices constraints and the Redis multi-provider section now describe the guard instead of the "same explicit prefix" caveat Tests: Sa.Outbox.Redis 37 (6 guard tests), Sa.Outbox 170, Sa.Outbox.PostgreSql 254, Sa.Outbox.MultiProviderTests 3.
Tenants are now resolved per provider, with the default provider as the shared fallback: - AddTenantSettings takes the provider key and registers a keyed TenantSettings; the default key also registers the unkeyed alias, so a single-provider application (and code resolving TenantSettings without a key) keeps its previous behaviour - IOutboxStorage gains TenantSettings(providerKey) (keyed first, shared fallback); IOutboxTenantDetector is resolved unkeyed first, because a detector registered without a key is an explicit global override, and the provider's own keyed detector otherwise - ITenantProvider.GetTenantIds(providerKey, ct); DeliveryProcessor passes settings.ProviderKey. This also fixes a real gap: with multi-provider, auto-detection for a non-default provider silently returned no tenants - OutboxPartitionalSupport carries its provider key, and both it and IDeliverySnapshot are registered keyed per provider (with the default key alias): PG migration/cleanup now enumerates the provider's own tenants and parts instead of the first provider's - the PG migration supports resolve the keyed partitional support Tests: Sa.Outbox 173 (per-provider settings and keyed detectors), Sa.Outbox.PostgreSql 255 (each provider enumerates its own tenants), Sa.Outbox.MultiProviderTests 4 (PG [1] vs Redis [2]), Redis 37.
- the hosted provider validator now also checks the inverse direction: every consumer group names the provider key its storage lives under, and a group registered under a scope with no provider fails the start with the offending scope key and the list of registered providers - this catches the classic mismatch — AddSaOutbox() with the default scope plus a provider registered under a custom key (or vice versa) — which previously surfaced only on the first delivery tick, with the pipeline resolving no storage - docs: the validation table row and the keyed follow-up now describe the check instead of "not checked" Tests: Sa.Outbox 177 (4 scope-key cases), Sa.Outbox.PostgreSql 255, Sa.Outbox.Redis 37, Sa.Outbox.MultiProviderTests 4.
- IOutboxProviderInitializer is an optional keyed provider hook; the core keeps OutboxProviderInitialization, a memoized task per provider key shared by every consumer group of that provider - DeliveryJob awaits the gate before ProcessMessages: an unavailable database now fails a known step, through the job's own error policy, instead of the first delivery tick (where ThenCloseApplication could take the host down). A failed attempt is removed from the cache, so the next tick retries; a cancelled waiter does not poison the cache - the gate is lazy rather than a hosted service, so the registration order of AddSaOutbox and the provider package does not matter - providers: PostgreSQL runs SELECT 1 on its data source, Redis runs PING - docs: the warm-up section and the implemented B follow-up Tests: Sa.Outbox 184 (once-only, retry-after-failure, cancelled waiter), Sa.Outbox.PostgreSql 255, Sa.Outbox.Redis 37, Sa.Outbox.MultiProviderTests 5 (warm-up over both providers).
WithEnabled(false) on IPgOutboxConfiguration / IRedisOutboxConfiguration is a registration switch, not a runtime flag: the configurator records its intents (settings, connection/data source, serializer, poison, Options actions) and applies nothing when disabled. - both configurators defer registration to Commit(); Setup creates the configurator, checks Enabled, commits only when enabled, and returns before registering the provider services, the core one-call overload, the consumer groups and the schedule - a disabled provider therefore leaves no trace in DI: no PgOutboxSettings, no keyed data source (whose ValidateOnStart would fail on an absent connection string), no Redis IDatabase/multiplexer, no serializer or poison override, no IOutboxProviderRegistry entry - Enabled defaults to true, so single-provider applications are unchanged - docs: turning the provider off in both provider readmes and the plug-point spec (incl. the split-form caveat: AddSaOutbox still registers its groups, so the startup scope-key check names them) Tests: Sa.Outbox.PostgreSqlTests 259 (4 new: nothing registered, no startup validator, enabled contrast, one disabled + one enabled key), Sa.Outbox.RedisTests 41 (4 new), MultiProvider 5; solution builds 0 warnings.
…tion
Follow-up to the Outbox code review.
Serializer (decided: per provider, shared fallback):
- WithMessageSerializer registers the serializer under the provider key, and the
provider's commands resolve it keyed, so a second provider no longer
overwrites the first one's codec
- a provider without an explicit serializer follows the container-level
registration (the core JSON serializer is the last fallback); the default key
keeps the unkeyed registration for the single-provider surface
- PG/Redis readme and the core contract docs updated
Idempotent re-registration of one provider key (decided: supported):
- the PG/Redis layout marker is replaced per key, so the multi-provider guard
no longer compares a provider with itself and fails the start
- PG skips a second data-source registration for a key: the first registration
owns the connection instead of hitting the "already configured" guard
- both provider readmes document the semantics
Redis prefix docs (there is no earlier release to keep keys for):
- drop the "set the prefix via WithOutboxSettings to keep old keys" advice; it
cannot work, because the :{key} suffix is applied after those values. Document
the Options(...) action, which runs last, as the way to pin an exact prefix
- tenants are per provider, not shared per container (stale line)
Warm-up fail-fast and duplicate group ids within one provider are intentional
and unchanged.
Tests: PG 262 (+3: keyed serializer, default unkeyed alias, idempotent
registration), Redis 45 (+4: keyed serializer, default alias, idempotent
registration, Options pins the prefix), MultiProvider 6 (+1: PG and Redis
resolve their own serializer); solution builds 0 warnings.
…'s database The default provider registers an unkeyed IDatabase alias for backward compatibility. Any provider registered later detected that alias as "an application-registered database" and took the UseRegisteredDatabase path, so its own connection string, database index or multiplexer was silently ignored and it wrote into the default provider's server/database. - the alias descriptor is recorded by an OutboxDatabaseAlias marker, and the "already provided" check ignores exactly that descriptor; a database the application registered itself still counts - the connection options and the Redis readme state the rule - tests: a default + keyed registration leaves UseRegisteredDatabase false for both, an application-provided IDatabase is still borrowed, and an end-to-end test publishes through a keyed provider into database 1 while the default provider's database 0 stays empty (this is the case that used to write into database 0) Redis suite 48 (3 new); solution builds 0 warnings.
…fault fallback Review follow-ups (High). WithPublishSettings was a silent no-op: the delegate took an immutable OutboxPublishSettings as Action, so `b.WithMaxBatchSize(...)` built a copy nobody used, and the unkeyed registration applied every callback to every provider. - the delegate is now Func<IServiceProvider, OutboxPublishSettings, OutboxPublishSettings> and each call contributes the next immutable snapshot - the delegate is keyed by the outbox scope, so providers keep their own publish settings; the default key keeps its unkeyed alias - the PG parallel-messaging test passed 1024 through the old no-op shape and is updated; new core tests cover the applied value and per-scope isolation DeliverySnapshot enumerated every provider's consumer group ids and resolved them by string. With a repeated group id the lookup threw inside the migration job, and with distinct ids a provider created partitions for another provider's groups. - DeliverySnapshot takes its provider key and resolves groups by OutboxGroupKey, so ConsumerSettings/GetConsumeGroupIds are provider-local - new test: two PG providers with the same group id, each snapshot exposes only its own group Keyed storage resolution fell back to the unkeyed registration for any key, so a publisher created for an unregistered non-default key silently used the default provider's storage (and the job validator validated the wrong registry). - OutboxProviderResolution.Required/Optional restrict the unkeyed fallback to the default key; a missing non-default contract is an InvalidOperationException naming the key - tenant settings deliberately keep the shared fallback (the documented per-provider tenant model); the tenant detector keeps its explicit global override - new test: publishing through an unknown key fails instead of writing to the default provider Tests: core 186 (+2), PG 264 (+2), Redis 48, MultiProvider 6; solution builds 0 warnings.
The memoized gate inserted its task after Task.Yield had already scheduled the initializer continuation. A synchronously faulting initializer (refused connection, ValueTask.FromException) could remove the not-yet-inserted entry, after which the faulted task was cached forever: every delivery tick replayed the same exception and the warm-up never retried. - publish a TaskCompletionSource with TryAdd before running the initializer, so the failure path always removes the entry it owns - keep cancellation semantics via TrySetCanceled - cache the completed no-op for providers without an initializer and check the cache before resolving the keyed initializer (no DI lookup per tick) - regression test resumes Task.Yield inline through a SynchronizationContext, which reproduces the old forever-cached failure deterministically Tests: Sa.Outbox 187 (+1), PG 264, Redis 48, MultiProvider 6.
IOutboxProviderInitializer.InitializeAsync accepted a token the core never passed and the implementations never used (Redis PingAsync has no overload that takes one), so the parameter only promised cancellation that did not happen. Passing a caller's token would be wrong anyway: the warm-up result is memoized and shared by every consumer group of the provider, so one group's cancellation must not cancel it. Only the wait around the gate observes the caller's token. - the hook is InitializeAsync(); the provider's own command/connection timeouts bound the work, and the docs say so - PG passes CancellationToken.None to SELECT 1 explicitly Tests: Sa.Outbox 188, PG 269, Redis 49, MultiProvider 6.
…ns its data source Review follow-ups (low). Three registrations that quietly accumulated state. Settings callbacks stacked once per registration: - the settings factories apply every action recorded for the key, and a repeated AddSaOutboxUsing* added that registration's callbacks on top, so one callback ran once per registration. PG (outbox and polling), Redis and the core publish settings now drop what the previous registration recorded for the same scope; several calls inside one registration still compose. - WithPublishSettings is documented for the first time: the delegate returns the next immutable snapshot (the old Action shape was a silent no-op), it is keyed by the scope, and a repeated registration replaces it. The Func change is a public API break worth naming in the readme. The data-source guard could not tell who registered it: - a keyed IPgDataSource under the key made the outbox skip its own WithDataSource(configure) even when another module (or a bare application call) registered it, silently dropping the connection string. - PgOutboxDataSourceMarker now records what the outbox owns. A repeat outbox registration is skipped; a bare foreign registration is borrowed (a bare WithDataSource adds nothing anyway); an explicit connection string against a foreign, already-configured key fails with the data source's own "already configured" error instead of being ignored. Tests: Sa.Outbox 188 (+1), PG 269 (+5: data source ownership x4, settings once), Redis 49 (+1). Each new test was checked against the pre-fix code.
The courier caught OperationCanceledException in the generic `!IsCritical()` handler and turned it into Warn(backoff), so a host shutdown burned a delivery attempt per message and could dead-letter a batch that was never attempted. Cancellation now rethrows with the cycle's own token — Sa.Schedule recognises a stop by that identity and ends the run silently — while a consumer's internal timeout still falls through as a real failure. The per-tenant catch was unfiltered too: it swallowed shutdown and kept walking every remaining tenant. It now absorbs only the linked PerTenantTimeout source and rethrows otherwise; the sequential loop also checks the token between tenants. Lock renewal: providers reported a lost lease by returning 0 instead of throwing, which LockRenewer cannot see. DeliveryTenant now treats `renewed == 0` as a lost lease, except once the pass has finished consuming — there the rows are already terminal and the renewer's last tick would race ReturnDelivery and abort a delivered batch. PostgreSQL's extend no longer gates on `lock_expires_on > now`: the column keeps unix seconds, so any sub-second LockDuration made every renewal match nothing, while ownership is already asserted by task_transact_id.
PublishSingle bypassed Send's per-chunk check and handed the token to a provider that cannot observe it — Redis has no CancellationToken on its async commands — so an already-cancelled publish appended the message and reported success. Both overloads now check the token, and the Redis command checks it before the first XADD, which is the last honest point. The contract is documented as best effort rather than transactional across the call: a publish larger than MaxBatchSize is split into independently committed chunks, so a cancellation between them keeps the chunks already committed and the exception carries no count. A caller that retries must be idempotent.
Documents what a cancelled delivery pass does to a batch: nothing is written, PostgreSQL keeps the row Processing and does not spend an attempt, Redis keeps the entry in the PEL but its delivery counter was already incremented at rent. Also records the renewal-vs-release exception and the duplicate window, with the tests that pin each half. Corrects FixedIntervalWaitStrategy being described as the default: the DI default is ExponentialIdleWaitStrategy, which degrades to fixed polling while IdleMaxInterval is zero and adaptive back-off is opt-in per group.
- add a Contents block with anchors to the 47 readmes that had none (`## Contents` / `## Содержание`, H2-H3, GitHub anchor rules) - cross-link every EN/RU readme pair at the top and give the empty AsLink placeholders a title - sync the outbox readmes with the code: status codes 0/100, RetryCountOnError has no -1 mode, the real TenantSettings surface, real PG table names, keyed manager overloads, WithRetentionPeriod, WithMinOffset(group, date), SqlBuilder has no ObjectPool, TypeResolve uses a SemaphoreSlim, one provider per key, and where consumer-group sections actually come from - link child docs from their parent contexts and fix broken in-page anchors
The provider's detail moves next to its source: `InMemory/Readme.md` (+ ru) covers what it is, the quick-start call, the file map, the behaviour table, the cancellation and retry semantics and the limitations that keep it out of production. The core readme now keeps a short pointer there instead of carrying a second copy that would drift. Also lists the provider in the "Available Providers" table, since the in-memory one ships inside Sa.Outbox rather than as its own package.
Add a `0. Grill` step before the spec, one committed root `GLOSSARY.md` as the single source of terms, and ADR-0002 recording the adoption. The grill skills themselves stay local (`.opencode/**` is git-ignored), pinned in `.opencode/skills/_upstream.md`.
SPEC-005. `Sa.Outbox.InMemory` implements the three plug-point contracts with a process-local store: one id map plus a per-(tenant, part, payload type) ordered index, in-process leases with rent generations, `AvailableAt` for Postpone/Retry, and an optional capacity that fails fast. Declared capabilities are `TenantDetection | LockExtension | Postponement`; `PublishContext` is absent and a non-null context throws. Payloads go through the core serializer, so the provider is an example of the real contract rather than a shortcut around it. Verified: Sa.Outbox.Tests 214/214 (15 new facts, no Docker), Sa.Outbox.PostgreSqlTests 275/275, Sa.Outbox.RedisTests 52/52, solution build green, sample runs without infrastructure. Sa.Outbox 0.18.0 -> 0.19.0.
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.
No description provided.