scoop:scoop.http.client:0.1.0
src/observability/lifetime.scoop
Selected production source · src/observability/lifetime.scoop
1
package scoop.http.client3
internal suspend fun runObservedClientCall(call: ClientCall) {4
coroutineScope<Unit> {5
val scope = this7
call.lock.withLock { call.observerScope = Some(scope) }8
try {9
startClientDeadline(10
call,11
scope,12
HttpTimeoutPhase.Total,13
call.timeouts.total,14
call.started15
)16
try {17
runClientCallWork(call)18
}19
catch (error: Throwable) {20
failClientCall(call, error, true)21
}22
releaseClientLease(call)23
finishClientObservation(call)24
emitClientEvent(call, HttpCallEventKind.Completed)25
} finally {26
try {27
closeFailedClientWebSocket(call)28
}29
finally {30
stopClientDeadlines(call)31
call.lock.withLock { call.observerScope = None }32
}33
}34
}35
}37
// The caller holds call.lock. An intentional response.close remains abandonment.38
internal fun clientObservedCallAcceptsCancellation(call: ClientCall): Boolean =39
clientPresent(call.observerScope) && (!call.abandoned || clientPresent(call.followUp))