From bc7f5d3bb16ba33a971ba983093e0fe1daf1d13a Mon Sep 17 00:00:00 2001 From: reshke Date: Tue, 2 Apr 2024 12:18:06 +0000 Subject: [PATCH] Implement DropKeyRange && DropAllKeyRanges in coordinator grpc service --- coordinator/provider/keyranges.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/coordinator/provider/keyranges.go b/coordinator/provider/keyranges.go index d81d7e1fd..a9ccd7658 100644 --- a/coordinator/provider/keyranges.go +++ b/coordinator/provider/keyranges.go @@ -16,6 +16,28 @@ type CoordinatorService struct { impl coordinator.Coordinator } +// DropAllKeyRanges implements proto.KeyRangeServiceServer. +func (c *CoordinatorService) DropAllKeyRanges(ctx context.Context, request *protos.DropAllKeyRangesRequest) (*protos.DropAllKeyRangesResponse, error) { + err := c.impl.DropKeyRangeAll(ctx) + if err != nil { + return nil, err + } + + return &protos.DropAllKeyRangesResponse{}, nil +} + +// DropKeyRange implements proto.KeyRangeServiceServer. +func (c *CoordinatorService) DropKeyRange(ctx context.Context, request *protos.DropKeyRangeRequest) (*protos.ModifyReply, error) { + for _, id := range request.Id { + err := c.impl.DropKeyRange(ctx, id) + if err != nil { + return nil, err + } + } + + return &protos.ModifyReply{}, nil +} + // TODO : unit tests func (c *CoordinatorService) CreateKeyRange(ctx context.Context, request *protos.CreateKeyRangeRequest) (*protos.ModifyReply, error) { err := c.impl.CreateKeyRange(ctx, kr.KeyRangeFromProto(request.KeyRangeInfo))