Skip to content

Instantly share code, notes, and snippets.

@PierreZ
Created July 2, 2018 18:57
Show Gist options
  • Save PierreZ/87bb3d9c332bbb19b2749a2b39574390 to your computer and use it in GitHub Desktop.
Save PierreZ/87bb3d9c332bbb19b2749a2b39574390 to your computer and use it in GitHub Desktop.
package hrpc
import (
"context"
"github.com/golang/protobuf/proto"
"github.com/tsuna/gohbase/pb"
)
// AssignRegion represents a AssignRegion Hbase call request.
// It assign a region to a server chosen at random.
type AssignRegion struct {
base
RegionName []byte
}
// Name returns the name of the rpc function
func (ar *AssignRegion) Name() string {
return "AssignRegion"
}
// NewAssignRegion creates a new NewAssignRegionStruct with default fields and the specified region
func NewAssignRegion(regionName []byte) *AssignRegion {
return &AssignRegion{
base{
ctx: context.Background(),
table: []byte{},
resultch: make(chan RPCResult, 1),
},
regionName,
}
}
// ToProto converts the RPC into a protobuf message
func (ar *AssignRegion) ToProto() proto.Message {
return &pb.AssignRegionRequest{
Region: &pb.RegionSpecifier{
Type: pb.RegionSpecifier_REGION_NAME.Enum(),
Value: ar.RegionName,
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment