forked from vapor/postgres-nio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectionPoolObservabilityDelegate.swift
62 lines (40 loc) · 2.59 KB
/
ConnectionPoolObservabilityDelegate.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public protocol ConnectionPoolObservabilityDelegate: Sendable {
associatedtype ConnectionID: Hashable & Sendable
/// The connection with the given ID has started trying to establish a connection. The outcome
/// of the connection will be reported as either ``connectSucceeded(id:streamCapacity:)`` or
/// ``connectFailed(id:error:)``.
func startedConnecting(id: ConnectionID)
/// A connection attempt failed with the given error. After some period of
/// time ``startedConnecting(id:)`` may be called again.
func connectFailed(id: ConnectionID, error: Error)
/// A connection was established on the connection with the given ID. `streamCapacity` streams are
/// available to use on the connection. The maximum number of available streams may change over
/// time and is reported via ````. The
func connectSucceeded(id: ConnectionID, streamCapacity: UInt16)
/// The utlization of the connection changed; a stream may have been used, returned or the
/// maximum number of concurrent streams available on the connection changed.
func connectionUtilizationChanged(id:ConnectionID, streamsUsed: UInt16, streamCapacity: UInt16)
func keepAliveTriggered(id: ConnectionID)
func keepAliveSucceeded(id: ConnectionID)
func keepAliveFailed(id: ConnectionID, error: Error)
/// The remote peer is quiescing the connection: no new streams will be created on it. The
/// connection will eventually be closed and removed from the pool.
func connectionClosing(id: ConnectionID)
/// The connection was closed. The connection may be established again in the future (notified
/// via ``startedConnecting(id:)``).
func connectionClosed(id: ConnectionID, error: Error?)
func requestQueueDepthChanged(_ newDepth: Int)
}
public struct NoOpConnectionPoolMetrics<ConnectionID: Hashable>: ConnectionPoolObservabilityDelegate {
public init(connectionIDType: ConnectionID.Type) {}
public func startedConnecting(id: ConnectionID) {}
public func connectFailed(id: ConnectionID, error: Error) {}
public func connectSucceeded(id: ConnectionID, streamCapacity: UInt16) {}
public func connectionUtilizationChanged(id: ConnectionID, streamsUsed: UInt16, streamCapacity: UInt16) {}
public func keepAliveTriggered(id: ConnectionID) {}
public func keepAliveSucceeded(id: ConnectionID) {}
public func keepAliveFailed(id: ConnectionID, error: Error) {}
public func connectionClosing(id: ConnectionID) {}
public func connectionClosed(id: ConnectionID, error: Error?) {}
public func requestQueueDepthChanged(_ newDepth: Int) {}
}