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

Provide rSocket path or some id in the reconnectable and interceptors callbacks #282

Open
vmalykhin opened this issue Nov 18, 2024 · 2 comments

Comments

@vmalykhin
Copy link

vmalykhin commented Nov 18, 2024

Is there an easy way to know the current RSocket instance by path (url or any other tag like id or hash) when processing errors in the reconnectable {...} block?

Android use case:
Ktor client creates a few instances of RSockets by ktorClient.rSocket(host, path, secure = true)with different path and keeps these sockets alive during app session.
Then after the disconnect/reconnect depending on business logic, the client might want to reconnect some socket instance immediately, but other sockets should be reconnected a bit later to prevent network overloading (say, 5-10 seconds later) or should not be reconnected at all.

I bit of pseudo code:

reconnectable { cause, attempt -> // no way to know on what exact rSocket instance it called?
  if (myInternalLogicHelper.isHighPriorityInstance(rSocket)) {
    true // reconnects now
  } else {
    delay(5000) // delay before next attempt
    true // or even `false` to not reconnect at all after error
  }
}

Also looks like there is no relation between initial RSocket created by ktorClient.rSocket(...) and rSocket object received in  interceptors -> forRequester.
Does RSocket URL (path) have public access somewhere?

Thanks in advance!

@vmalykhin vmalykhin changed the title Provide rSocket path or some id in the reconnectable and interceptors blocks Provide rSocket path or some id in the reconnectable and interceptors callbacks Nov 23, 2024
@whyoleg
Copy link
Member

whyoleg commented Nov 26, 2024

Hey, unfortunately, there is no easy way currently.
Do you think, that may be alternatively adding ability to configure reconnectable logic on call size will help here?
E.g something like:

ktorClient.rSocket {
  reconnectable { ... }
}

Currently, reconnecting functionality was implemented rather ad-hoc and needs redesign and should be aligned with potential client-load-balancing feature.

Does RSocket URL (path) have public access somewhere?

Not, but there are related issues: #187 and #231. There is no design for this at this moment

@vmalykhin
Copy link
Author

Thanks for the feedback.
Yeah, putting reconnectable declaration somewhere in "create new rsocket" call would help.

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

No branches or pull requests

2 participants