lnrpc+lncli: add TerminateSession command

This commit is contained in:
Elle Mouton
2023-11-29 11:06:07 +02:00
parent 24702ede14
commit 5d16491c13
9 changed files with 657 additions and 216 deletions

View File

@@ -35,6 +35,10 @@ type WatchtowerClientClient interface {
// is not considered for session negotiation. Its sessions will also not
// be used while the tower is inactive.
DeactivateTower(ctx context.Context, in *DeactivateTowerRequest, opts ...grpc.CallOption) (*DeactivateTowerResponse, error)
// lncli: `wtclient session terminate`
// Terminate terminates the given session and marks it as terminal so that
// it is not used for backups anymore.
TerminateSession(ctx context.Context, in *TerminateSessionRequest, opts ...grpc.CallOption) (*TerminateSessionResponse, error)
// lncli: `wtclient towers`
// ListTowers returns the list of watchtowers registered with the client.
ListTowers(ctx context.Context, in *ListTowersRequest, opts ...grpc.CallOption) (*ListTowersResponse, error)
@@ -84,6 +88,15 @@ func (c *watchtowerClientClient) DeactivateTower(ctx context.Context, in *Deacti
return out, nil
}
func (c *watchtowerClientClient) TerminateSession(ctx context.Context, in *TerminateSessionRequest, opts ...grpc.CallOption) (*TerminateSessionResponse, error) {
out := new(TerminateSessionResponse)
err := c.cc.Invoke(ctx, "/wtclientrpc.WatchtowerClient/TerminateSession", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *watchtowerClientClient) ListTowers(ctx context.Context, in *ListTowersRequest, opts ...grpc.CallOption) (*ListTowersResponse, error) {
out := new(ListTowersResponse)
err := c.cc.Invoke(ctx, "/wtclientrpc.WatchtowerClient/ListTowers", in, out, opts...)
@@ -141,6 +154,10 @@ type WatchtowerClientServer interface {
// is not considered for session negotiation. Its sessions will also not
// be used while the tower is inactive.
DeactivateTower(context.Context, *DeactivateTowerRequest) (*DeactivateTowerResponse, error)
// lncli: `wtclient session terminate`
// Terminate terminates the given session and marks it as terminal so that
// it is not used for backups anymore.
TerminateSession(context.Context, *TerminateSessionRequest) (*TerminateSessionResponse, error)
// lncli: `wtclient towers`
// ListTowers returns the list of watchtowers registered with the client.
ListTowers(context.Context, *ListTowersRequest) (*ListTowersResponse, error)
@@ -169,6 +186,9 @@ func (UnimplementedWatchtowerClientServer) RemoveTower(context.Context, *RemoveT
func (UnimplementedWatchtowerClientServer) DeactivateTower(context.Context, *DeactivateTowerRequest) (*DeactivateTowerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeactivateTower not implemented")
}
func (UnimplementedWatchtowerClientServer) TerminateSession(context.Context, *TerminateSessionRequest) (*TerminateSessionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method TerminateSession not implemented")
}
func (UnimplementedWatchtowerClientServer) ListTowers(context.Context, *ListTowersRequest) (*ListTowersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListTowers not implemented")
}
@@ -248,6 +268,24 @@ func _WatchtowerClient_DeactivateTower_Handler(srv interface{}, ctx context.Cont
return interceptor(ctx, in, info, handler)
}
func _WatchtowerClient_TerminateSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TerminateSessionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(WatchtowerClientServer).TerminateSession(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/wtclientrpc.WatchtowerClient/TerminateSession",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(WatchtowerClientServer).TerminateSession(ctx, req.(*TerminateSessionRequest))
}
return interceptor(ctx, in, info, handler)
}
func _WatchtowerClient_ListTowers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListTowersRequest)
if err := dec(in); err != nil {
@@ -339,6 +377,10 @@ var WatchtowerClient_ServiceDesc = grpc.ServiceDesc{
MethodName: "DeactivateTower",
Handler: _WatchtowerClient_DeactivateTower_Handler,
},
{
MethodName: "TerminateSession",
Handler: _WatchtowerClient_TerminateSession_Handler,
},
{
MethodName: "ListTowers",
Handler: _WatchtowerClient_ListTowers_Handler,