You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Overview
This PR refactors the egress tracking system to use asynchronous batch
processing instead of synchronous invocation execution. The freeway
gateway now serializes egress tracking invocations and sends them to a
Cloudflare Queue, where the
[egress-consumer](https://github.com/storacha/egress-consumer) processes
them in batches before forwarding to the upload-api in a CAR with
multiple invocations.
## Key Changes
### Freeway Gateway (Producer)
Modified the egress tracking middleware to serialize invocations instead
of executing them immediately:
- Removed the direct connection to upload-api from withEgressClient
- Invocations are now built, converted to IPLD view using
buildIPLDView(), and archived to bytes
- Serialized invocations are sent to EGRESS_QUEUE as message payloads
- Egress Tracking controlled using feature flags:
`FF_EGRESS_TRACKER_ENABLED` & `FF_EGRESS_TRACKER_ROLLOUT_PERCENTAGE`
## Flow
1. Gateway serves content and creates an egress record invocation
2. Invocation is archived to bytes and queued
3. Cloudflare Queue batches messages (configured batch size: 50,
timeout: 30s)
4. Egress-consumer receives batch, extracts invocations
5. Consumer builds CAR message with all invocations
6. Single POST to upload-api processes entire batch
7. Upload-api executes each invocation and records egress in
DynamoDB+Stripe
## Additional Changes
- Added missing `dev` packages
- Fixed type issues
- Fixed build issues
- Fixed tests
- Updated `package-lock.json`
0 commit comments