Skip to content
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

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

fforbeck
Copy link
Member

@fforbeck fforbeck commented Nov 22, 2024

Added the nonce as suggested per @alanshaw, but also set it to not expire, so we can process the invocation any time. The servedAt field doesn't need to be converted to seconds.

Blocked by storacha/w3infra#443 & storacha/w3up#1588

@fforbeck fforbeck requested review from travis and alanshaw November 22, 2024 18:39
@fforbeck fforbeck self-assigned this Nov 22, 2024
@fforbeck fforbeck merged commit b135643 into main Nov 25, 2024
1 check passed
@fforbeck fforbeck deleted the fix/egress-record-invocation branch November 25, 2024 14:11
},
expiration: Infinity, // Don't expire the invocation, so we can record egress any time
Copy link
Member

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.

Copy link
Member Author

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(),
Copy link
Member

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).

Copy link
Member Author

@fforbeck fforbeck Nov 25, 2024

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?

fforbeck pushed a commit that referenced this pull request Dec 19, 2024
🤖 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>
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.

3 participants