github.com/tsuna/gohbase@v0.0.0-20250731002811-4ffcadfba63e/hrpc/balancer.go (about)

     1  // Copyright (C) 2020  The GoHBase Authors.  All rights reserved.
     2  // This file is part of GoHBase.
     3  // Use of this source code is governed by the Apache License 2.0
     4  // that can be found in the COPYING file.
     5  
     6  package hrpc
     7  
     8  import (
     9  	"context"
    10  
    11  	"github.com/tsuna/gohbase/pb"
    12  	"google.golang.org/protobuf/proto"
    13  )
    14  
    15  // SetBalancer allows to enable or disable balancer
    16  type SetBalancer struct {
    17  	base
    18  	req *pb.SetBalancerRunningRequest
    19  }
    20  
    21  // NewSetBalancer creates a new SetBalancer request that will set balancer state.
    22  func NewSetBalancer(ctx context.Context, enabled bool) (*SetBalancer, error) {
    23  	return &SetBalancer{
    24  		base: base{
    25  			ctx:      ctx,
    26  			resultch: make(chan RPCResult, 1),
    27  		},
    28  		req: &pb.SetBalancerRunningRequest{On: &enabled},
    29  	}, nil
    30  }
    31  
    32  // Name returns the name of this RPC call.
    33  func (sb *SetBalancer) Name() string {
    34  	return "SetBalancerRunning"
    35  }
    36  
    37  // Description returns the description of this RPC call.
    38  func (sb *SetBalancer) Description() string {
    39  	return sb.Name()
    40  }
    41  
    42  // ToProto converts the RPC into a protobuf message.
    43  func (sb *SetBalancer) ToProto() proto.Message {
    44  	return sb.req
    45  }
    46  
    47  // NewResponse creates an empty protobuf message to read the response of this RPC.
    48  func (sb *SetBalancer) NewResponse() proto.Message {
    49  	return &pb.SetBalancerRunningResponse{}
    50  }