-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(egress-client): set nonce, expire and fix servedAt #130
Conversation
}, | ||
expiration: Infinity, // Don't expire the invocation, so we can record egress any time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is necessary, and I don't think the upload service should be able to record egress for this resource forever...just when it receives this invocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to include this here explicitly because I was thinking about the rollout for Phase 2 (storacha/project-tracking#192). In this phase, I plan to integrate a queue in Cloudflare worker to receive the egress events, with consumers responsible for signing and forwarding these requests to the Upload-API. This setup would allow us to fine-tune the duration for which these events are recorded, likely based on the throughput of the consumers. Also, this code would probably be moved to the consumer.
}, | ||
expiration: Infinity, // Don't expire the invocation, so we can record egress any time | ||
nonce: process.hrtime().toString(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the partition key is now milliseconds precision we should probably also use that here right? At the moment we'd end up with multiple invocations recorded but only a single row in the DB (in the same millisecond). Using Date.now()
here would mean we'd see the same number of invocations as DB rows (i.e. one in the same millisecond).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanshaw I'm not sure I fully understand. My assumption was that in the context of generating a nonce, process.hrtime()
would provide a more precise and unique value, particularly in a high-frequency execution environment. Does it need to align with the servedAt
field (using Date.now())? I guess they are intended to function independently, no?
🤖 I have created a release *beep* *boop* --- ## [2.22.0](v2.21.0...v2.22.0) (2024-12-19) ### Features * egress client - ucanto integration ([#123](#123)) ([22bed68](22bed68)) * enable egress tracking in production env ([#135](#135)) ([ad43b62](ad43b62)) * **indexer:** probabilistic feature flag ([#136](#136)) ([dca2b35](dca2b35)) * ucan invocation handler ([#133](#133)) ([b199bfa](b199bfa)) * Use Indexing Service when feature flag is present ([#132](#132)) ([fa3f480](fa3f480)) ### Bug Fixes * **config:** staging kv bidding ([#134](#134)) ([7a523d5](7a523d5)) * **egress-client:** set nonce, expire and fix servedAt ([#130](#130)) ([b135643](b135643)) * enable open telemetry for all envs ([#131](#131)) ([c822465](c822465)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Added the
nonce
as suggested per @alanshaw, but also set it to not expire, so we can process the invocation any time. TheservedAt
field doesn't need to be converted to seconds.Blocked by storacha/w3infra#443 & storacha/w3up#1588