mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-29 15:10:37 +00:00
grpc: add shutdown call for external management (#957)
* grpc: add shutdown call for external management * go mod: tidy * glorious: suggestion * Update engine/engine.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update engine/rpcserver.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update main.go Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> * Update engine/rpcserver.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
@@ -2304,3 +2304,24 @@ func TestGetCollateral(t *testing.T) {
|
||||
t.Errorf("received '%v', expected '%v'", err, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShutdown(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := RPCServer{Engine: &Engine{}}
|
||||
_, err := s.Shutdown(context.Background(), &gctrpc.ShutdownRequest{})
|
||||
if !errors.Is(err, errShutdownNotAllowed) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, errShutdownNotAllowed)
|
||||
}
|
||||
|
||||
s.Engine.Settings.EnableGRPCShutdown = true
|
||||
_, err = s.Shutdown(context.Background(), &gctrpc.ShutdownRequest{})
|
||||
if !errors.Is(err, errGRPCShutdownSignalIsNil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, errGRPCShutdownSignalIsNil)
|
||||
}
|
||||
|
||||
s.Engine.GRPCShutdownSignal = make(chan struct{}, 1)
|
||||
_, err = s.Shutdown(context.Background(), &gctrpc.ShutdownRequest{})
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user