本文整理匯總了Golang中git/curoverse/com/arvados/git/sdk/go/keepclient.KeepClient.Ask方法的典型用法代碼示例。如果您正苦於以下問題:Golang KeepClient.Ask方法的具體用法?Golang KeepClient.Ask怎麽用?Golang KeepClient.Ask使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類git/curoverse/com/arvados/git/sdk/go/keepclient.KeepClient
的用法示例。
在下文中一共展示了KeepClient.Ask方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: performKeepBlockCheck
// Get block headers from keep. Log any errors.
func performKeepBlockCheck(kc *keepclient.KeepClient, blobSignatureTTL time.Duration, blobSigningKey string, blockLocators []string, verbose bool) error {
totalBlocks := len(blockLocators)
notFoundBlocks := 0
current := 0
for _, locator := range blockLocators {
current++
if verbose {
log.Printf("Verifying block %d of %d: %v", current, totalBlocks, locator)
}
getLocator := locator
if blobSigningKey != "" {
expiresAt := time.Now().AddDate(0, 0, 1)
getLocator = keepclient.SignLocator(locator, kc.Arvados.ApiToken, expiresAt, blobSignatureTTL, []byte(blobSigningKey))
}
_, _, err := kc.Ask(getLocator)
if err != nil {
notFoundBlocks++
log.Printf("Error verifying block %v: %v", locator, err)
}
}
log.Printf("Verify block totals: %d attempts, %d successes, %d errors", totalBlocks, totalBlocks-notFoundBlocks, notFoundBlocks)
if notFoundBlocks > 0 {
return fmt.Errorf("Block verification failed for %d out of %d blocks with matching prefix.", notFoundBlocks, totalBlocks)
}
return nil
}