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

Add support for ping command in Pub/Sub mode #454

Open
sagaxu opened this issue Jul 12, 2024 · 0 comments
Open

Add support for ping command in Pub/Sub mode #454

sagaxu opened this issue Jul 12, 2024 · 0 comments

Comments

@sagaxu
Copy link

sagaxu commented Jul 12, 2024

It's nice to use ping command to check if the connection is still alive.

  • It almost works currently, except
  • RedisConnection.toReceiveChannel is broken.

if ((reply != null && reply.type() == ResponseType.PUSH) || empty) {

  1. run in pubsub mode
  2. call conn.toReceiveChannel, it will pause the stream first, then call ReadStream.fetch(1)
  3. run ping command and redis server reply with pong
  4. the handle in RedisStandaloneConnection didn't dispatch the reply of ping to onMessage
  5. so nobody will call stream.fetch(1), the stream can't receive any more
private class ChannelReadStream<T>(val stream: ReadStream<T>,
                                   val channel: Channel<T>,
                                   context: Context) : Channel<T> by channel, CoroutineScope {

  override val coroutineContext: CoroutineContext = context.dispatcher()

  fun subscribe() {
    stream.endHandler {
      close()
    }
    stream.exceptionHandler { err ->
      close(err)
    }
    stream.handler { event ->
      launch {
        send(event)
        stream.fetch(1)
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant