Commits


Konstantin Varlamov authored and GitHub committed 84ca4aa36bc
gRPC: make `GrpcConnection` monitor connectivity status and quickly end calls on change (#1897) Summary of code changes: * `GrpcConnection` now keeps track of all outstanding calls. To make this uniform, `GrpcStream` and `GrpcStreamingReader` now implement an interface, `GrpcCall`, that has two methods: `FinishImmediately` and `FinishAndNotify`. These two methods differ in that only the latter notifies observers; * `GrpcConnection` invokes `FinishAndNotify` on all active calls each time connectivity changes. Since `FinishAndNotify` notifies observers, the behavior is pretty much as if the calls were failed by gRPC; * `GrpcConnection` now has `Shutdown` method that quickly finishes all active calls (invoking `Finish`, which doesn't notify the observers). That bit of functionality is moved from `Datastore`; * `GrpcStream` and `GrpcStreamingReader` register and unregister themselves with `GrpcConnection`; * `GrpcStream` now implements both `FinishImmediately` and `FinishAndNotify`, which delegate most of the work to a new private member function, `Shutdown`. Summary of test changes: * Make `GrpcStreamTester` delegate creation of `GrpcStream`/etc. to `GrpcConnection`; * Refactor gRPC-queue-related code out of `GrpcStreamTester` into a new class, `FakeGrpcQueue`; * Add a tag (`Start`/`Read`/etc.) to `GrpcCompletion`. This is just to aid debugging (allow visually checking which pending completions does a gRPC call have); * Fix a couple of ordering issues in `GrpcStream` exposed by refactored tests.