Skip to content

[TON-372] Multitenant webhooks#195

Open
g3co wants to merge 24 commits into
masterfrom
multitenant-webhooks
Open

[TON-372] Multitenant webhooks#195
g3co wants to merge 24 commits into
masterfrom
multitenant-webhooks

Conversation

@g3co

@g3co g3co commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds multitenant wallet webhooks with support for dynamic config loading and periodic refresh.

g3co added 3 commits March 17, 2026 17:30
…moving the old handler. Update main application to utilize the new service for wallet webhooks. Clean up configuration by removing unused WebhookURL variable.
@github-actions

github-actions Bot commented Mar 17, 2026

Copy link
Copy Markdown

📊 Performance Metrics

Performance Metrics (memory storage)

  • CPU: 1.00s (4 cores) • Goroutines: 8 • Threads: 7
  • Memory: 22.2MB heap • 49.9MB RAM • 42.7MB total • 274546 allocs
  • GC: 11 cycles (0.16ms avg)
  • FDs: 9/65536 (0.0%)

…e management. Update various webhook-related functions to handle errors gracefully and improve code clarity by using underscore for ignored return values.
@github-actions

github-actions Bot commented Mar 17, 2026

Copy link
Copy Markdown

📊 Performance Metrics

Performance Metrics (postgres storage)

  • CPU: 1.14s (4 cores) • Goroutines: 10 • Threads: 10
  • Memory: 16.7MB heap • 53.0MB RAM • 42.2MB total • 296448 allocs
  • GC: 12 cycles (0.27ms avg)
  • FDs: 35/65536 (0.1%)

@github-actions

github-actions Bot commented Mar 17, 2026

Copy link
Copy Markdown

📊 Performance Metrics

Performance Metrics (cluster-valkey storage)

  • CPU: 0.94s (4 cores) • Goroutines: 11 • Threads: 11
  • Memory: 25.4MB heap • 58.5MB RAM • 39.6MB total • 328560 allocs
  • GC: 11 cycles (0.56ms avg)
  • FDs: 71/65536 (0.1%)

g3co added 4 commits March 17, 2026 19:37
…ook tests

- Added `WALLET_LIST_URL` and `WALLET_LIST_REFRESH_INTERVAL` to `docker-compose.dnsmasq.yml` and `docker-compose.nginx.yml` for wallet integration.
- Refactored webhook tests to utilize a shared mock server and improved handling of webhook readiness and record management.
- Changed `WALLET_LIST_URL` from `http://bridge-gointegration:9091/wallets` to `http://gointegration:9091/wallets` across multiple Docker Compose files for consistency.
- Updated `WEBHOOK_MOCK_HOST` from `bridge-gointegration` to `gointegration` in relevant services to reflect the new configuration.
@github-actions

github-actions Bot commented Mar 17, 2026

Copy link
Copy Markdown

📊 Performance Metrics

Performance Metrics (nginx storage)

  • CPU: 0.13s (4 cores) • Goroutines: 6 • Threads: 6
  • Memory: 1.2MB heap • 23.1MB RAM • 1.2MB total • 5892 allocs
  • GC: 0 cycles (0ms avg)
  • FDs: 14/65536 (0.0%)

@github-actions

github-actions Bot commented Mar 17, 2026

Copy link
Copy Markdown

📊 Performance Metrics

Performance Metrics (dnsmasq storage)

  • CPU: 0.35s (4 cores) • Goroutines: 11 • Threads: 7
  • Memory: 1.9MB heap • 23.8MB RAM • 10.4MB total • 67068 allocs
  • GC: 7 cycles (0.17ms avg)
  • FDs: 16/65536 (0.0%)

g3co added 12 commits March 18, 2026 12:23
- Replaced the previous WALLET_LIST_URL and WALLET_LIST_REFRESH_INTERVAL with a new WEBHOOK_CONFIG environment variable for per-wallet webhook settings.
- Updated the main application and webhook service to utilize the new configuration format, allowing for individual wallet URLs and optional authentication tokens.
- Adjusted Docker Compose files and documentation to reflect these changes, ensuring consistency across services.
…on token

- Modified the WEBHOOK_CONFIG environment variable across multiple Docker Compose files to include an authentication token for the test wallet.
- Updated related tests to validate the presence of the authorization header in webhook requests.
…onfiguration

- Updated the webhook service to allow configuration from both inline JSON and an optional file/URL source.
- Introduced a refresh mechanism for source-backed configurations, ensuring updates are applied periodically.
- Enhanced documentation to reflect the new configuration options and their usage.
- Added tests to validate loading and merging of webhook configurations from different sources.
…or notifications

- Modified the webhook service to ensure that notifications are only sent when both `wallet` and `topic` query parameters are present.
- Updated related documentation to clarify the new requirement for webhook payloads.
- Refactored tests to validate the behavior when the `topic` parameter is omitted, ensuring no notifications are sent in such cases.
@g3co g3co requested a review from TrueCarry March 18, 2026 19:04
@g3co g3co changed the title Multitenant webhooks [TON-372] Multitenant webhooks Mar 19, 2026
Comment thread docs/WEBHOOKS.md Outdated
Comment thread docs/WEBHOOKS.md
Comment thread internal/webhook/service.go
Comment thread internal/webhook/service.go Outdated
@g3co g3co requested a review from TrueCarry March 23, 2026 07:46
@g3co

g3co commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Why this can't be deployed as-is

The multitenant wallet-webhook feature is functionally complete, but it can't ship until the SDK is updated.

Webhook duplication — needs an SDK update first

The webhook fires once per POST /bridge/message, on the instance that received it, and is not deduplicated
(internal/v3/handler/handler.go:366, internal/v1/handler/handler.go:378; the v1 TransferedCache check feeds a metric only and does
not gate the webhook).

Because the SDK can connect to two different bridges at once, a single logical send produces two POSTs → two webhook deliveries
to the wallet endpoint. The SDK must first be updated to select a single bridge so there is exactly one source of truth; otherwise
every notification is duplicated. (Retried POSTs duplicate as well, since there is no dedup gate.)

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