Skip to content

Feat/supabase subscriber#149

Merged
toopay merged 7 commits intomainfrom
feat/supabase-subscriber
Feb 20, 2026
Merged

Feat/supabase subscriber#149
toopay merged 7 commits intomainfrom
feat/supabase-subscriber

Conversation

@vani-rf
Copy link
Copy Markdown
Contributor

@vani-rf vani-rf commented Feb 20, 2026

Add Supabase Realtime as a second Pub/Sub provider, enabling subscribers to listen to real-time database changes, broadcast messages, and presence events via WebSocket (Phoenix Channels protocol).

This PR refactors the pubsub architecture from Google-only to multi-provider, then adds the Supabase Realtime provider on top.

What changed

Architecture (commit 74e743d):

  • Refactored PubSubManager to use map-based provider registry (map[PubSubProviderType]PubSubProvider)
  • Extracted Google provider to pkg/pubsub/google/ (no circular dependency)
  • Added provider-agnostic SubscriberMessage wrapper
  • Added WrapLegacySubscriber for backward compatibility

Supabase Realtime Provider (commit c1ad763):

  • New pkg/pubsub/supabase/provider.go — WebSocket client with Phoenix channels protocol, 30s heartbeat, exponential backoff reconnect
  • Supports all 3 channel types: Broadcast, Presence, Postgres Changes
  • Added ChannelType(), Table(), Schema(), EventFilter() to SubscriberHandler interface with non-breaking defaults in SubscriberBase
  • Added RealtimeEventFilter string constants in pkg/supabase/constants (RealtimeEventAll, RealtimeEventInsert, RealtimeEventUpdate, RealtimeEventDelete)
  • Reuses existing config (SupabasePublicUrl, AnonKey, ServiceKey) — no new env vars
  • Root adapter (SupabaseRealtimeProvider) maps Realtime messages to SubscriberMessage

Type of change

  • New feature (non-breaking change which adds functionality)
  • Unit Tests

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Commands Run

golangci-lint run # clean
go vet ./... # clean
go test ./... # all pass
go test -cover ./pkg/pubsub/supabase/ # 86.3% coverage

Further comments

  • Non-breaking: Adding methods to SubscriberHandler is safe because all subscribers must embed SubscriberBase (required for code generation detection), which provides defaults.
  • No new env vars: Supabase Realtime derives WebSocket URL from SupabasePublicUrl and authenticates with ServiceKey/AnonKey.
  • OpenSpec spec updated with 3 new requirements (Supabase Realtime, Postgres Changes Filtering, SubscriberBase Code Gen Detection). Change proposal archived.

vani-rf and others added 6 commits February 20, 2026 22:36
- Split Google Pub/Sub implementation into pkg/pubsub/google/provider.go
- Replace single provider field with map-based provider registry
- Move Serve() into PubSubProvider interface (provider-owned push handling)
- Add SubscriberMessage wrapper replacing raw any in Consume signature
- Add backward compatibility: WrapLegacySubscriber, deprecated type aliases
- Update mocks, tests, and examples for new interfaces
- Add docs/pubsub.md documentation
- Add openspec/specs/pubsub/spec.md specification
- Fill out openspec/project.md with project details

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add pkg/pubsub/supabase/ provider with WebSocket client, Phoenix channels
  protocol, heartbeat, reconnect, broadcast/presence/postgres_changes support
- Add SupabaseRealtimeProvider adapter in pubsub.go with DefaultWebSocketDialer
- Add ChannelType, Table, Schema, EventFilter methods to SubscriberHandler interface
- Add RealtimeEventFilter constants in pkg/supabase/constants
- Add unit tests for provider (86.3% coverage) and adapter
- Fix errcheck lint issues in Google Serve handler
- Update docs/pubsub.md with Supabase Realtime section and examples
- Update openspec specs and archive change proposal

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Examples directory is gitignored and should not be part of PR changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 68 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/pubsub/supabase/provider.go 81.95% 27 Missing and 8 partials ⚠️
pubsub.go 84.57% 27 Missing and 6 partials ⚠️
Flag Coverage Δ
go-1.22 73.58% <83.33%> (+0.53%) ⬆️
go-1.24 72.89% <83.33%> (+0.62%) ⬆️
go-1.25 72.87% <83.33%> (+0.67%) ⬆️
macos-latest 73.38% <83.33%> (+0.31%) ⬆️
ubuntu-latest 73.66% <83.33%> (+0.60%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pubsub.go 83.58% <84.57%> (+34.01%) ⬆️
pkg/pubsub/supabase/provider.go 81.95% <81.95%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add tests for subscriberContext, SubscriberBase defaults, PubSubManager.Serve
branches, legacy adapter methods, GooglePubSubProvider.Serve/CreateSubscription,
and SupabaseRealtimeProvider adapter methods.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vani-rf vani-rf requested review from mul14 and toopay February 20, 2026 17:30
@toopay toopay merged commit bad9bf0 into main Feb 20, 2026
19 checks passed
@toopay toopay deleted the feat/supabase-subscriber branch February 24, 2026 11:37
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.

2 participants