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

Introduce subscription support in the Wallet crate. #473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crodas
Copy link
Contributor

@crodas crodas commented Nov 25, 2024

Description

The last bit missing to wrap up #442

The main goal is to add a subscription to CDK Mint updates into the wallet. This feature will be particularly useful for improving the code whenever loops hit the mint server to check status changes.

The goal is to add an easy-to-use interface that will hide the fact that we're connecting to WebSocket and subscribing to events. This will also hide the fact that the CDK-mint server may not support WebSocket updates.

To be fully backward compatible, the HttpClientMethods traits have a new method, subscribe, which will return an object that implements ActiveSubscription.

In the primary implementation, there is a SubscriptionClient that will attempt to connect through WebSocket and will fall to the HTTP-status pull and sleep approach (the current approach), but upper stream code will receive updates as if they come from a stream of updates through WebSocket. This SubscriptionClient struct will also manage reconnections to WebSockets (with automatic resubscriptions) and all the low-level stuff, providing an easy-to-use interface and leaving the upper-level code with a nice interface that is hard to misuse. When ActiveSubscription is dropped, it will automatically unsubscribe.


Notes to the reviewers


Suggested CHANGELOG Updates

Added Websocket subscription to the Wallet.

CHANGED

ADDED

REMOVED

FIXED


Checklist

@crodas crodas force-pushed the web-socket-for-wallet branch 7 times, most recently from 2ff8f0b to 8990de4 Compare November 27, 2024 14:51
@crodas crodas marked this pull request as draft November 27, 2024 15:23
@crodas crodas force-pushed the web-socket-for-wallet branch 4 times, most recently from 259d800 to 3e3fa23 Compare November 28, 2024 11:54
@crodas crodas marked this pull request as ready for review November 28, 2024 11:56
The main goal is to add a subscription to CDK Mint updates into the wallet.
This feature will be particularly useful for improving the code whenever loops
hit the mint server to check status changes.

The goal is to add an easy-to-use interface that will hide the fact that we're
connecting to WebSocket and subscribing to events. This will also hide the fact
that the CDK-mint server may not support WebSocket updates.

To be fully backward compatible, the HttpClientMethods traits have a new
method, `subscribe,` which will return an object that implements
`ActiveSubscription.`

In the primary implementation, there is a `SubscriptionClient` that will
attempt to connect through WebSocket and will fall to the HTTP-status pull and
sleep approach (the current approach), but upper stream code will receive
updates as if they come from a stream of updates through WebSocket. This
`SubscriptionClient` struct will also manage reconnections to WebSockets (with
automatic resubscriptions) and all the low-level stuff, providing an
easy-to-use interface and leaving the upper-level code with a nice interface
that is hard to misuse. When `ActiveSubscription` is dropped, it will
automatically unsubscribe.
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.

1 participant