Created
July 2, 2018 18:57
-
-
Save PierreZ/87bb3d9c332bbb19b2749a2b39574390 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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