本文整理汇总了Golang中github.com/cockroachdb/cockroach/server/serverpb.ClusterFreezeResponse.RangesAffected方法的典型用法代码示例。如果您正苦于以下问题:Golang ClusterFreezeResponse.RangesAffected方法的具体用法?Golang ClusterFreezeResponse.RangesAffected怎么用?Golang ClusterFreezeResponse.RangesAffected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cockroachdb/cockroach/server/serverpb.ClusterFreezeResponse
的用法示例。
在下文中一共展示了ClusterFreezeResponse.RangesAffected方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: postFreeze
func postFreeze(c cluster.Cluster, freeze bool, timeout time.Duration) (serverpb.ClusterFreezeResponse, error) {
httpClient := cluster.HTTPClient
httpClient.Timeout = timeout
var resp serverpb.ClusterFreezeResponse
log.Infof("requesting: freeze=%t, timeout=%s", freeze, timeout)
cb := func(v proto.Message) {
oldNum := resp.RangesAffected
resp = *v.(*serverpb.ClusterFreezeResponse)
if oldNum > resp.RangesAffected {
resp.RangesAffected = oldNum
}
if (resp != serverpb.ClusterFreezeResponse{}) {
log.Infof("%+v", &resp)
}
}
err := util.StreamJSON(
httpClient,
c.URL(0)+"/_admin/v1/cluster/freeze",
&serverpb.ClusterFreezeRequest{Freeze: freeze},
&serverpb.ClusterFreezeResponse{},
cb,
)
return resp, err
}
示例2: TestClusterFreeze
func TestClusterFreeze(t *testing.T) {
defer leaktest.AfterTest(t)()
s := StartTestServer(t)
defer s.Stop()
for _, freeze := range []bool{true, false} {
req := serverpb.ClusterFreezeRequest{
Freeze: freeze,
}
var resp serverpb.ClusterFreezeResponse
cb := func(v proto.Message) {
oldNum := resp.RangesAffected
resp = *v.(*serverpb.ClusterFreezeResponse)
if oldNum > resp.RangesAffected {
resp.RangesAffected = oldNum
}
}
cli, err := s.ctx.GetHTTPClient()
if err != nil {
t.Fatal(err)
}
path := s.Ctx.AdminURL() + apiEndpoint + "cluster/freeze"
if err := util.StreamJSON(cli, path, &req, &serverpb.ClusterFreezeResponse{}, cb); err != nil {
t.Fatal(err)
}
if aff := resp.RangesAffected; aff == 0 {
t.Fatalf("expected affected ranges: %+v", resp)
}
if err := util.StreamJSON(cli, path, &req, &serverpb.ClusterFreezeResponse{}, cb); err != nil {
t.Fatal(err)
}
}
}