-
Notifications
You must be signed in to change notification settings - Fork 13
fix(egress-client): set nonce, expire and fix servedAt #130
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,8 +89,10 @@ async function record (space, resource, bytes, servedAt, env, ctx) { | |
| nb: { | ||
| resource, | ||
| bytes, | ||
| servedAt: Math.floor(servedAt.getTime() / 1000) | ||
| servedAt: servedAt.getTime() | ||
| }, | ||
| expiration: Infinity, // Don't expire the invocation, so we can record egress any time | ||
| nonce: process.hrtime().toString(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, |
||
| proofs: ctx.delegationProofs | ||
| }) | ||
| const res = await invocation.execute(connection) | ||
|
|
||
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.