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

feat: egress client - ucanto integration #123

Merged
merged 19 commits into from
Nov 13, 2024
Merged

Conversation

fforbeck
Copy link
Member

@fforbeck fforbeck commented Oct 31, 2024

Egress Client - UCanto Integration

Context

This PR introduces EgressClient to the application context, enabling capability invocations such as Space.egressRecord for logging egress directly to the UCanto Server (Upload API). With this integration, the previous Accounting Service is now replaced by a method in EgressClient for egress logging.

Key Changes

  • Middleware Integration: Added withEgressClient middleware to simplify capability invocations across the application.

  • EgressClient Creation: Introduced a create function to instantiate UCantoClient, establishing a secure connection to the UCanto Server based on environment configurations.

  • Egress Recording: Refactored EgressClient.record function to use the Space.egressRecord capability, allowing for efficient egress byte tracking in our infrastructure.

  • Connection Management: Added a connect function to handle connection setup with the UCanto Server.

  • Environment Variables: Updated the environment variables, including service Web DIDs and service URLs.

  • Enhanced Context: Added the delegationProofs to the application context, so we can use that information to invoke the egressRecord capabilities. Also added the GatewayIdentity to the application context.

  • Accounting Service: There is no Accounting Service anymore. Instead, we use the EgressClient to record the egress event.

  • Wrangler: Updated the configs for all environments and the wrangler lib to the latest version.

  • Telemetry: Added a feature flag for Open Telemetry - if enabled, the Egress Record call will fail to execute the this.fetch function call. See Fix opentelemetry issue caused in the execution of the invocation project-tracking#176 for more details.

@fforbeck fforbeck changed the title feat/ucanto integration feat: ucanto integration Oct 31, 2024
@fforbeck fforbeck marked this pull request as ready for review October 31, 2024 14:21
Copy link
Member

@Peeja Peeja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫵🥫➡️❗

Looks great! One suggestion:

src/middleware/withUcantoClient.js Outdated Show resolved Hide resolved
Copy link
Member

@travis travis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! agree with Petra but happy to see this ship with or without the change

@fforbeck fforbeck changed the title feat: ucanto integration feat: egress client - ucanto integration Nov 7, 2024
Copy link
Member

@Peeja Peeja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Suggestions and thoughts below. Looks like this needs some type love and some npm run lint:fixing too.

src/index.js Outdated Show resolved Hide resolved
src/middleware/index.js Outdated Show resolved Hide resolved
src/middleware/withAuthorizedSpace.js Outdated Show resolved Hide resolved
src/middleware/withAuthorizedSpace.types.ts Outdated Show resolved Hide resolved
src/middleware/withAuthorizedSpace.js Show resolved Hide resolved
src/middleware/withAuthorizedSpace.types.ts Show resolved Hide resolved
src/middleware/withEgressClient.js Outdated Show resolved Hide resolved
src/middleware/withEgressClient.js Outdated Show resolved Hide resolved
test/helpers/builder.js Show resolved Hide resolved
@fforbeck fforbeck self-assigned this Nov 13, 2024
@fforbeck fforbeck merged commit 22bed68 into main Nov 13, 2024
1 check passed
@fforbeck fforbeck deleted the feat/ucanto-integration branch November 13, 2024 19:03
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