本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/server/serverpb.ClusterFreezeResponse類的典型用法代碼示例。如果您正苦於以下問題:Golang ClusterFreezeResponse類的具體用法?Golang ClusterFreezeResponse怎麽用?Golang ClusterFreezeResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ClusterFreezeResponse類的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(context.Background(), "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(context.Background(), "%+v", &resp)
}
}
err := httputil.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, _, _ := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().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.GetHTTPClient()
if err != nil {
t.Fatal(err)
}
path := s.AdminURL() + adminPrefix + "cluster/freeze"
if err := httputil.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 := httputil.StreamJSON(cli, path, &req, &serverpb.ClusterFreezeResponse{}, cb); err != nil {
t.Fatal(err)
}
}
}