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:
Ryan O'Hara-Reid
2022-05-20 11:20:39 +10:00
committed by GitHub
parent c492e6600e
commit ee9c35d5ee
13 changed files with 1194 additions and 853 deletions

View File

@@ -118,6 +118,7 @@ type GoCryptoTraderServiceClient interface {
CurrencyStateTradingPair(ctx context.Context, in *CurrencyStateTradingPairRequest, opts ...grpc.CallOption) (*GenericResponse, error)
GetFuturesPositions(ctx context.Context, in *GetFuturesPositionsRequest, opts ...grpc.CallOption) (*GetFuturesPositionsResponse, error)
GetCollateral(ctx context.Context, in *GetCollateralRequest, opts ...grpc.CallOption) (*GetCollateralResponse, error)
Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error)
}
type goCryptoTraderServiceClient struct {
@@ -1130,6 +1131,15 @@ func (c *goCryptoTraderServiceClient) GetCollateral(ctx context.Context, in *Get
return out, nil
}
func (c *goCryptoTraderServiceClient) Shutdown(ctx context.Context, in *ShutdownRequest, opts ...grpc.CallOption) (*ShutdownResponse, error) {
out := new(ShutdownResponse)
err := c.cc.Invoke(ctx, "/gctrpc.GoCryptoTraderService/Shutdown", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// GoCryptoTraderServiceServer is the server API for GoCryptoTraderService service.
// All implementations must embed UnimplementedGoCryptoTraderServiceServer
// for forward compatibility
@@ -1230,6 +1240,7 @@ type GoCryptoTraderServiceServer interface {
CurrencyStateTradingPair(context.Context, *CurrencyStateTradingPairRequest) (*GenericResponse, error)
GetFuturesPositions(context.Context, *GetFuturesPositionsRequest) (*GetFuturesPositionsResponse, error)
GetCollateral(context.Context, *GetCollateralRequest) (*GetCollateralResponse, error)
Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error)
mustEmbedUnimplementedGoCryptoTraderServiceServer()
}
@@ -1525,6 +1536,9 @@ func (UnimplementedGoCryptoTraderServiceServer) GetFuturesPositions(context.Cont
func (UnimplementedGoCryptoTraderServiceServer) GetCollateral(context.Context, *GetCollateralRequest) (*GetCollateralResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetCollateral not implemented")
}
func (UnimplementedGoCryptoTraderServiceServer) Shutdown(context.Context, *ShutdownRequest) (*ShutdownResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented")
}
func (UnimplementedGoCryptoTraderServiceServer) mustEmbedUnimplementedGoCryptoTraderServiceServer() {}
// UnsafeGoCryptoTraderServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -3284,6 +3298,24 @@ func _GoCryptoTraderService_GetCollateral_Handler(srv interface{}, ctx context.C
return interceptor(ctx, in, info, handler)
}
func _GoCryptoTraderService_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ShutdownRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GoCryptoTraderServiceServer).Shutdown(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gctrpc.GoCryptoTraderService/Shutdown",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GoCryptoTraderServiceServer).Shutdown(ctx, req.(*ShutdownRequest))
}
return interceptor(ctx, in, info, handler)
}
// GoCryptoTraderService_ServiceDesc is the grpc.ServiceDesc for GoCryptoTraderService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -3651,6 +3683,10 @@ var GoCryptoTraderService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetCollateral",
Handler: _GoCryptoTraderService_GetCollateral_Handler,
},
{
MethodName: "Shutdown",
Handler: _GoCryptoTraderService_Shutdown_Handler,
},
},
Streams: []grpc.StreamDesc{
{