feat(server): stop when the host asks - #5
Merged
Merged
Conversation
A go-plugin host stops a plugin by calling GRPCController.Shutdown and waiting a grace period for the process to exit, then kills it. This library did not serve that service, so a C++ plugin answered Unimplemented, kept running, and was always killed: nothing after Wait() in its main ever ran. PluginServer now serves the controller. Its one method takes and returns plugin.Empty, zero bytes on the wire, so it is registered over raw byte buffers, the way generated code registers a method, and a consumer's build needs no extra code generation. The request arrives on a gRPC thread, which cannot wait for its own server to shut down, so it hands the stop to the parent-death watchdog thread, which already carries out the stop when the host dies. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
CI and the preset built every dependency for x64-linux, vcpkg's default, which builds each twice: debug and release. The host tools (protoc and grpc_cpp_plugin) share that triplet, since target and host are the same machine. CI builds Release and nothing links the debug copies. x64-linux-release, vcpkg's release-only triplet, is now both target and host. Moving only the host, as the plugins did, would add a second build here instead of removing one, because this repository's target triplet is not release-only. The example's go:generate follows the protoc path. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@coderabbitai ignore
Two commits:
Stop when the host asks
A go-plugin host stops a plugin in three steps:
GRPCController.Shutdown;This library did not serve
GRPCController, so a C++ plugin answeredUnimplementedand kept running. It was always killed, so nothing afterWait()in itsmainever ran, and neither did the teardown there.PluginServernow serves the controller./plugin.GRPCController/Shutdown, takes and returnsplugin.Empty, which is zero bytes on the wire. So it is registered over rawgrpc::ByteBuffers, the way generated code registers a method. That needs no.protoand no code generation, so a consumer's build, a vcpkg port for instance, needs noprotocas an extra build tool.Shutdown()as it already does when the host dies.Wait()then returns andmainunwinds.Build vcpkg's dependencies release-only
CI and the
vcpkgpreset built every dependency forx64-linux, vcpkg's default, which builds each dependency twice: debug and release. The host tools (protoc,grpc_cpp_plugin) share that triplet, because target and host are the same machine. CI builds Release, so nothing links the debug copies.x64-linux-release, vcpkg's release-only triplet, is now both the target and the host triplet. Switching only the host would add a second build here rather than remove one, since the target triplet was not release-only. The example'sgo:generatefollowsprotocto the new install path.Tested
All 30 tests pass.
New
Server.StopsWhenTheHostAskstest: it calls/plugin.GRPCController/Shutdownthe way go-plugin does, and expectsWait()to return with nothing else callingShutdown().UnimplementedandWait()never returns.CI steps replayed from a clean vcpkg install on the new triplet, in 6 min 44 s:
ctest;go generateand build.Only an
x64-linux-releasetree was installed.🤖 Generated with Claude Code