mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
[fleet] move http ktor engine related code to rpc.server.ktor
GitOrigin-RevId: 09aee497f8c5f532380918456c3a2a1a0f0e13cb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7968a25171
commit
ca98770be4
@@ -8,40 +8,45 @@ import fleet.rpc.client.rpcClient
|
||||
import fleet.rpc.core.Serialization
|
||||
import fleet.rpc.core.Transport
|
||||
import fleet.rpc.core.TransportMessage
|
||||
import fleet.tracing.spannedScope
|
||||
import fleet.util.UID
|
||||
import fleet.util.async.async
|
||||
import fleet.util.async.resource
|
||||
import fleet.util.async.use
|
||||
import fleet.util.async.*
|
||||
import fleet.util.channels.channels
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
suspend fun RequestDispatcher.withDirectRpcClient(serialization: () -> Serialization,
|
||||
interceptor: RpcInterceptor,
|
||||
body: suspend CoroutineScope.(IRpcClient) -> Unit) {
|
||||
spannedScope("withDirectRpcClient") {
|
||||
fun RequestDispatcher.directRpcClient(
|
||||
serialization: () -> Serialization,
|
||||
interceptor: RpcInterceptor,
|
||||
): Resource<IRpcClient> =
|
||||
resource { cc ->
|
||||
val (dispatcherSend, clientReceive) = channels<TransportMessage>(Channel.BUFFERED)
|
||||
val (clientSend, dispatcherReceive) = channels<TransportMessage>(Channel.BUFFERED)
|
||||
val origin = UID.random()
|
||||
resource<IRpcClient> { continuation ->
|
||||
launch {
|
||||
handleConnection(route = origin,
|
||||
endpoint = EndpointKind.Client,
|
||||
send = dispatcherSend,
|
||||
receive = dispatcherReceive,
|
||||
presentableName = "directRpcClient")
|
||||
}.use {
|
||||
rpcClient(transport = Transport(outgoing = clientSend, incoming = clientReceive),
|
||||
serialization = serialization,
|
||||
origin = origin,
|
||||
requestInterceptor = interceptor) { rpcClient ->
|
||||
continuation(rpcClient)
|
||||
}
|
||||
launch {
|
||||
handleConnection(route = origin,
|
||||
endpoint = EndpointKind.Client,
|
||||
send = dispatcherSend,
|
||||
receive = dispatcherReceive,
|
||||
presentableName = "directRpcClient")
|
||||
}.use {
|
||||
rpcClient(transport = Transport(outgoing = clientSend, incoming = clientReceive),
|
||||
serialization = serialization,
|
||||
origin = origin,
|
||||
requestInterceptor = interceptor) { rpcClient ->
|
||||
cc(rpcClient)
|
||||
}
|
||||
}.async().use { rpcClientDeferred ->
|
||||
}
|
||||
}.span("directRpcClient")
|
||||
|
||||
suspend fun RequestDispatcher.withDirectRpcClient(
|
||||
serialization: () -> Serialization,
|
||||
interceptor: RpcInterceptor,
|
||||
body: suspend CoroutineScope.(IRpcClient) -> Unit,
|
||||
) {
|
||||
directRpcClient(serialization, interceptor)
|
||||
.async()
|
||||
.use { rpcClientDeferred ->
|
||||
body(promisingRpcClient(rpcClientDeferred))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ class FleetService private constructor(val serviceId: UID,
|
||||
job.join()
|
||||
}
|
||||
|
||||
//@fleet.kernel.plugins.InternalInPluginModules(where = ["fleet.app.fleet.tests"])
|
||||
suspend fun terminate(cause: String) {
|
||||
terminate(CancellationException(cause))
|
||||
}
|
||||
@@ -50,7 +49,7 @@ class FleetService private constructor(val serviceId: UID,
|
||||
}
|
||||
}
|
||||
}.use { serviceJob ->
|
||||
body(FleetService(providerId, serviceJob))
|
||||
body(FleetService(serviceId = providerId, job = serviceJob))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.coroutines.EmptyCoroutineContext
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
//@fleet.kernel.plugins.InternalInPluginModules(where = ["fleet.app.fleet.tests"])
|
||||
class RpcExecutor private constructor(private val serialization: () -> Serialization,
|
||||
private val services: RpcServiceLocator,
|
||||
private val route: UID,
|
||||
|
||||
Reference in New Issue
Block a user