-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏗️ Receive shutdown signal via RPC and terminate the gRPC server.
- Loading branch information
1 parent
e4ccec2
commit e50cee1
Showing
3 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/robertograham/tpp4j/DefaultGrpcController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.github.robertograham.tpp4j; | ||
|
||
import com.hashicorp.goplugin.Empty; | ||
import com.hashicorp.goplugin.GRPCControllerGrpc.GRPCControllerImplBase; | ||
import io.grpc.stub.StreamObserver; | ||
|
||
final class DefaultGrpcController extends GRPCControllerImplBase { | ||
|
||
final ProviderServer providerServer; | ||
|
||
DefaultGrpcController(final ProviderServer providerServer) { | ||
this.providerServer = providerServer; | ||
} | ||
|
||
@Override | ||
public void shutdown(final Empty request, final StreamObserver<Empty> responseObserver) { | ||
System.err.println("[INFO] Shutting down"); | ||
|
||
providerServer.stop(); | ||
|
||
responseObserver.onNext(Empty.newBuilder() | ||
.build()); | ||
responseObserver.onCompleted(); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
syntax = "proto3"; | ||
package plugin; | ||
option go_package = "./plugin"; | ||
option java_multiple_files = true; | ||
option java_package = "com.hashicorp.goplugin"; | ||
|
||
message Empty { | ||
} | ||
|
||
// The GRPCController is responsible for telling the plugin server to shutdown. | ||
service GRPCController { | ||
rpc Shutdown(Empty) returns (Empty); | ||
} |