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