Repository navigation
Extract Program.cs into reusable AddRiftCacheCore()/MapRiftCacheCore() - #16
Merged
Merged
Conversation
First, standalone-valuable piece of the "wire AzureBlobPersistenceProvider into the Azure Container Apps deployment" ROADMAP follow-up. Program.cs was plain top-level statements -- no way for a different composed entry point (the future RiftCache.Azure project) to reuse the core service's wiring without copy-pasting it. Fixes that generally: any future provider (AWS, GCP, or a second Azure variant) needs the same composability, not just this one. Pure behavior-preserving extraction, verified as such rather than assumed: the existing WebApplicationFactory<Program>-based integration tests (CacheEndpointsTests, MultiTenantCacheEndpointsTests) boot the whole app and exercise every route, and all 73 existing tests pass completely unchanged. Also ran the refactored service directly and re-exercised the full single-tenant curl flow (root banner, healthz, 401/set/get/refresh/delete) to confirm real runtime behavior matches, not just what the automated tests happen to cover -- multi-tenant wasn't manually re-verified this way since Bash doesn't support hyphens in env var names (RIFTCACHE_API_KEY__TEAM-A isn't valid `VAR=value` syntax), but MultiTenantCacheEndpointsTests already covers that exact code path and passed. AddRiftCacheCore(IServiceCollection, IConfiguration) in the new RiftCacheServiceCollectionExtensions.cs moves every DI registration verbatim. MapRiftCacheCore(IEndpointRouteBuilder, RiftCacheServerOptions) in RiftCacheEndpointRouteBuilderExtensions.cs wraps the root banner, /healthz, and the existing MapCacheEndpoints call -- CacheEndpoints.cs itself is untouched. One real fix along the way, not just relocation: the root banner's version lookup used typeof(Program).Assembly, which only worked because Program lived in this same file/project. Now that this logic is reusable, it's anchored to typeof(RiftCacheServerOptions) instead -- a type guaranteed to live in the core assembly regardless of which entry point (this one, or a future composed one) actually hosts it. Confirmed via curl that the banner still reports the correct version after the change. Added RiftCacheServiceCollectionExtensionsTests.cs with the test that actually matters for this refactor's stated purpose: registering AddRiftCacheCore() then a fake IPersistenceProvider afterward resolves to the fake, not the default -- proving the "last registration wins, so a composed entry point can layer Azure providers on top without a removal step" claim actually holds, not just asserting it in a comment. Also fixed two more stale ARCHITECTURE_NOTES.md references (renamed to ARCHITECTURE.md several PRs ago) found while touching this area -- grepped the whole repo afterward to confirm none remain. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
First, standalone-valuable piece of the "wire AzureBlobPersistenceProvider into the Azure Container Apps deployment" ROADMAP follow-up. Program.cs was plain top-level statements -- no way for a different composed entry point (the future RiftCache.Azure project) to reuse the core service's wiring without copy-pasting it. Fixes that generally: any future provider (AWS, GCP, or a second Azure variant) needs the same composability, not just this one.
Pure behavior-preserving extraction, verified as such rather than assumed: the existing WebApplicationFactory-based integration tests (CacheEndpointsTests, MultiTenantCacheEndpointsTests) boot the whole app and exercise every route, and all 73 existing tests pass completely unchanged. Also ran the refactored service directly and re-exercised the full single-tenant curl flow (root banner, healthz, 401/set/get/refresh/delete) to confirm real runtime behavior matches, not just what the automated tests happen to cover -- multi-tenant wasn't manually re-verified this way since Bash doesn't support hyphens in env var names (RIFTCACHE_API_KEY__TEAM-A isn't valid
VAR=valuesyntax), but MultiTenantCacheEndpointsTests already covers that exact code path and passed.AddRiftCacheCore(IServiceCollection, IConfiguration) in the new RiftCacheServiceCollectionExtensions.cs moves every DI registration verbatim. MapRiftCacheCore(IEndpointRouteBuilder, RiftCacheServerOptions) in RiftCacheEndpointRouteBuilderExtensions.cs wraps the root banner, /healthz, and the existing MapCacheEndpoints call -- CacheEndpoints.cs itself is untouched.
One real fix along the way, not just relocation: the root banner's version lookup used typeof(Program).Assembly, which only worked because Program lived in this same file/project. Now that this logic is reusable, it's anchored to typeof(RiftCacheServerOptions) instead -- a type guaranteed to live in the core assembly regardless of which entry point (this one, or a future composed one) actually hosts it. Confirmed via curl that the banner still reports the correct version after the change.
Added RiftCacheServiceCollectionExtensionsTests.cs with the test that actually matters for this refactor's stated purpose: registering AddRiftCacheCore() then a fake IPersistenceProvider afterward resolves to the fake, not the default -- proving the "last registration wins, so a composed entry point can layer Azure providers on top without a removal step" claim actually holds, not just asserting it in a comment.
Also fixed two more stale ARCHITECTURE_NOTES.md references (renamed to ARCHITECTURE.md several PRs ago) found while touching this area -- grepped the whole repo afterward to confirm none remain.