Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ actual class Channel private constructor(val channel: ManagedChannel) {

actual suspend fun shutdown() {
channel.shutdown()

awaitTermination()
}

Expand All @@ -129,4 +128,8 @@ actual class Channel private constructor(val channel: ManagedChannel) {
}
}
}

actual fun resetConnectBackoff() {
channel.resetConnectBackoff()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ expect class Channel {
*/
fun withClientIdentity(certificate: Certificate, key: PrivateKey): Builder


/**
* Construct the channel
*
Expand All @@ -93,6 +94,15 @@ expect class Channel {
*/
suspend fun shutdown()


/**
* For subchannels that are in TRANSIENT_FAILURE state, short-circuit the backoff timer and make them reconnect immediately
*
* This is primarily intended for Android users, where the network may experience frequent temporary drops. Rather than waiting for gRPC's name resolution and reconnect timers to elapse before reconnecting, the app may use this method as a mechanism to notify gRPC that the network is now available and a reconnection attempt may occur immediately.
*
* No-op if not supported by the implementation.
*/
fun resetConnectBackoff()
/**
* Initiates a forceful shutdown of the gRPC channel. After invoking this method, no new calls
* can be started, and ongoing calls are immediately canceled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ actual class Channel private constructor(
override fun cleanupResources() {
client.close()
}

actual fun resetConnectBackoff() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ actual class Channel private constructor(
init(ENABLE_TRACE_LOGGING)
}
}

actual fun resetConnectBackoff() {}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think the function should also work in the native implementation and reset the backoff timer. Is there a reason you did not include it in the implementation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I was thinking the same thing but I don't have experience with Rust and it's more complicated to implement there. I'll still be testing but for some reason tonic works differently and so far I haven't seen any issues with reconnection on iOS

}

private fun installCertificates(
Expand Down