-
Notifications
You must be signed in to change notification settings - Fork 419
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
Extract the connection monitor from the connection manager #1173
Conversation
66ec32e
to
afdc96c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One brief note inline.
Motivation: The connection monitor allows users to register a delegate for changes in connectivity state as well as access the current state. Because the user code may call out it is executed on a `DispatchQueue` (rather than the connection's `EventLoop`). However, there are cases within gRPC where state change notifications on the event loop are very useful (such as in a pool of connection managers all running on the same event loop). Moreover, it's not necessary for the connection manager to hold the connection monitor, it just needs a way to inform it about any changes so that it can call any user provided delegates. Modifications: - Extract the connectivity monitor from the connection manager - Allow on-event-loop callbacks to be passed to the connection manager for connection state changes and for certain HTTP/2 events (stream closed and receiving max concurrent streams settings). While not strictly necessary for this change they will be helpful down the line. - Update a bunch of tests. Result: The connection manager no longer holds a connection monitor and may execute state change callbacks on the event loop.
afdc96c
to
72b4b61
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. LGTM!
@@ -1025,6 +1012,106 @@ extension ConnectionManagerTests { | |||
XCTAssertNoThrow(try shutdown.wait()) | |||
} | |||
} | |||
|
|||
func testHTTP2Delegates() throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: do we need the throws
here?
Motivation:
The connection monitor allows users to register a delegate for changes
in connectivity state as well as access the current state. Because the
user code may call out it is executed on a
DispatchQueue
(rather thanthe connection's
EventLoop
).However, there are cases within gRPC where state change notifications
on the event loop are very useful (such as in a pool of connection
managers all running on the same event loop).
Moreover, it's not necessary for the connection manager to hold the
connection monitor, it just needs a way to inform it about any changes
so that it can call any user provided delegates.
Modifications:
for connection state changes and for certain HTTP/2 events (stream
closed and receiving max concurrent streams settings). While not
strictly necessary for this change they will be helpful down the line.
Result:
The connection manager no longer holds a connection monitor and may
execute state change callbacks on the event loop.