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

Pluggable api client #440

Merged
merged 12 commits into from
Aug 23, 2023
Merged

Pluggable api client #440

merged 12 commits into from
Aug 23, 2023

Conversation

neekolas
Copy link
Contributor

@neekolas neekolas commented Aug 21, 2023

Summary

  • Creates an interface type for ApiClient to allow for alternative implementations
  • Allows the user to override the default ApiClient creation process with their own implementation
  • Adds a bunch of exports to the package to facilitate building your own ApiClient implementation
  • Moves all base64 decoding into the ApiClient instead of handling in the application
  • Changes return type of subscribe method, to support future changes which will allow updating content topics without closing the stream

Solves

#438

Notes

Bit of backstory on the base64 decoding. The code generator for GRPC gateway is inconsistent with the envelope type. When sending a message, you can provide the message field as a Uint8Array. But when receiving messages, it returns that field as a base64 encoded string. In order to provide a consistent API that matches the new type definition, we need to consolidate that logic in the HttpApiClient. This also just feels tidier.

This is a breaking change and will go into the next major SDK release

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 21, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: e9dc1d3
Status: ✅  Deploy successful!
Preview URL: https://8f42d3d6.xmtp-js.pages.dev
Branch Preview URL: https://nmolnar-pluggable-api-client.xmtp-js.pages.dev

View logs

@neekolas neekolas marked this pull request as ready for review August 21, 2023 22:13
@neekolas neekolas requested a review from a team August 21, 2023 22:13
@neekolas neekolas changed the base branch from main to beta August 22, 2023 18:04
@neekolas neekolas requested a review from jhaaaa as a code owner August 22, 2023 18:04
Copy link
Contributor

@mkobetic mkobetic left a comment

Choose a reason for hiding this comment

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

Looks like nice clean up.

@neekolas neekolas merged commit 20610be into beta Aug 23, 2023
@neekolas neekolas deleted the nmolnar/pluggable-api-client branch August 23, 2023 15:49
@github-actions
Copy link
Contributor

🎉 This PR is included in version 11.0.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants