Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

FM-427: HybridClient #462

Merged
merged 1 commit into from
Dec 18, 2023
Merged

FM-427: HybridClient #462

merged 1 commit into from
Dec 18, 2023

Conversation

aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Dec 8, 2023

Fixes consensus-shipyard/ipc#159

Replaces the use of the WebSocketClient in the Ethereum API facade with a new HybridClient that wraps it and uses a normal HttpClient as well as a WebSocketClient under the hood. The former should be more resilient as it doesn't maintain a persistent connection with CometBFT, while the latter is managed by a HybridClientDriver that reconnects if it encounters the "failed to send to internal channel" error.

With this solution the ethapi container should heal itself and doesn't need to be restarted. In the event of the CometBFT connection being dropped, the active WebSocket subscriptions from our own clients should get an error when they try to consume the data, resulting in those connections being closed, forcing them to re-subscribe.

@aakoshh aakoshh requested review from adlrocha and raulk December 8, 2023 14:21
let query = query.clone();
Box::pin(async move { client.unsubscribe(query.clone()).await })
})
.await;
Copy link
Contributor Author

@aakoshh aakoshh Dec 8, 2023

Choose a reason for hiding this comment

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

Just realised again that if the unsubscription there is probably no need to repeat this loop, the new client would most likely not be subscribed to anything. There is hopefully no harm doing it though, and it keeps the error handling tucked away.

@aakoshh aakoshh force-pushed the fm-427-ethapi-broken-socket branch from 3df7a2f to 792a4b7 Compare December 8, 2023 14:43
@aakoshh aakoshh merged commit 287d281 into main Dec 18, 2023
5 checks passed
@aakoshh aakoshh deleted the fm-427-ethapi-broken-socket branch December 18, 2023 13:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IPC-4] Eth API re-establish WebSocketClient?
1 participant