Skip to content

feat: forward writes from passive regions to active #691 - #730

Closed
Fading-Dev wants to merge 1 commit into
Stellabill:mainfrom
Fading-Dev:feat/cross-region-write-forward
Closed

Fading-Dev wants to merge 1 commit into
Stellabill:mainfrom
Fading-Dev:feat/cross-region-write-forward

Conversation

@Fading-Dev

Copy link
Copy Markdown

Overview

This PR implements active–passive cross-region write forwarding: passive regions proxy or redirect mutating HTTP requests to the configured active region, with hop-loop protection and a clear failure mode when the active region is unreachable.

Related Issue

Closes #691

Changes

🌍 Region Write Forwarding

  • [ADD] internal/middleware/region_router.go

    • Passive-role middleware forwards/redirects non-safe methods to ACTIVE_REGION_URL.
    • Supports proxy and redirect modes via REGION_FORWARD_MODE.
    • Sets X-Region-Hop: 1 and returns 508 on loop detection; 503 when active is unreachable.
  • [ADD] internal/middleware/region_router_test.go

    • Coverage for active passthrough, proxy/redirect modes, hop loops, and unreachable active.
  • [MODIFY] internal/config/config.go

    • Add REGION_ROLE, ACTIVE_REGION_URL, REGION_FORWARD_MODE, REGION_FORWARD_AUTH_TOKEN.
  • [MODIFY] internal/routes/routes.go

    • Wire RegionRouterMiddleware early in the global middleware chain.
  • [ADD] docs/CROSS_REGION_WRITE_FORWARDING.md

    • Operator guide for topology roles and forwarding modes.

Verification Results

go test ./internal/middleware/ -run Region -count=1
✅ PASS
Acceptance Criteria Status
Passive region forwards/redirects writes to active ✅ proxy + redirect modes
Hop loops detected ✅ 508 via X-Region-Hop
Unreachable active fails safely ✅ 503
Active region serves writes locally ✅ Role=active passthrough

Add RegionRouter middleware so passive regions proxy or redirect
mutating requests to the active region and reject hop loops.
@drips-wave

drips-wave Bot commented Aug 4, 2026

Copy link
Copy Markdown

@Godswillopeyemihub Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add cross-region write forwarding for the active-passive topology

2 participants