Skip to content

str-421: refactor GeyserGrpcClient types#721

Merged
lvboudre merged 2 commits intomasterfrom
str-421
Mar 31, 2026
Merged

str-421: refactor GeyserGrpcClient types#721
lvboudre merged 2 commits intomasterfrom
str-421

Conversation

@lvboudre
Copy link
Copy Markdown
Contributor

@lvboudre lvboudre commented Mar 30, 2026

Current issues

  • Leaky uncustomizable Generic Interceptor type : our client type GeyserGrpcClient expect an "interceptor" to inject x-token. This generic type is leaked all over our API, though users (customers) cannot customize this type at all, so it pollutes everyone else code because of this and integrate poorly with NAPI sdk which does not handle generic type verywell and forces us to do unsafe downcasting casting.

  • Leaky abstraction around subscribe impl Sink whose error types is fixed to futures::channel::error::SendError. In other words, because of the error type, we are leaking this underlying channel implementation. It is not abstract at all.
    Moreover, we use anonymous types which has more constraint at compile time than having the concrete type in the first place.

  • As we are building auto reconnect feature in STR-404: Yellowstone-grpc-client stream auto-reconnect #717 , it's easier to implement generic connector logic if the Stream returned by subscribe is not an anonymous type.

After the PR

  • Removed generic interceptor types from GeyserGrpcClient
  • Replaced impl Sink<SubscribeRequest, Error = mpsc::SendError> + use<F> with SubscribeRequestSink type.
  • Replaced impl Stream<Item = Result<SubscribeUpdate, Status>> + use<F> with GeyserStream type.
  • Applied similar type strategy for deshredded method too.
  • SubscribeRequestSinknow returns SubscribeRequestSinkError instead of mpsc::SendError.
  • Added more documentations on most important method.
  • retrofitted client.rs in our example folder.
  • Removed GeyserGrpcClientError::SubscribeSendError variant as no code branch could raise this error.

TL;DR: instead of returning leaky anonymous types like impl Sink and impl Stream we will return concrete types which will hide the underlying sink or stream. This will give us the flexibility to change the implementation when we want without breaking API in the future while providing a cleaner API with concrete types.

Copy link
Copy Markdown
Contributor

@leafaar leafaar left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

@WilfredAlmeida WilfredAlmeida left a comment

Choose a reason for hiding this comment

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

LGTM

@lvboudre lvboudre merged commit 4609d34 into master Mar 31, 2026
6 checks passed
@lvboudre lvboudre deleted the str-421 branch March 31, 2026 15:38
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