本文整理汇总了Golang中github.com/tpjg/goriakpbc.Client.NewBucket方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.NewBucket方法的具体用法?Golang Client.NewBucket怎么用?Golang Client.NewBucket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tpjg/goriakpbc.Client
的用法示例。
在下文中一共展示了Client.NewBucket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: killBucket
func killBucket(con *riak.Client, bucketName string) error {
bucket, err := con.NewBucket(bucketName)
if err != nil {
return err
}
keys, err := bucket.ListKeys()
if err != nil {
return err
}
wg := sync.WaitGroup{}
wg.Add(len(keys))
for _, key := range keys {
go func(key string) {
defer wg.Done()
obj, err := bucket.Get(string(key))
if obj == nil {
panic(err)
}
err = obj.Destroy()
if err != nil {
panic(err)
}
}(string(key))
}
wg.Wait()
return nil
}
示例2: RssMasterPollFeeds
func RssMasterPollFeeds(con *riak.Client, InputCh chan<- url.URL, OutputCh <-chan FeedError) {
bucket, err := con.NewBucket("feeds")
if err != nil {
log.Println("Failed to get feed bucket:", err)
}
// -62135596800 is Go's zero time according to Unix's time format. This is what empty feeds have for their check time.
// Nothing should appear before that.
keys_to_poll, err := bucket.IndexQueryRange(NextCheckIndexName, "-62135596800", strconv.FormatInt(time.Now().Unix(), 10))
var errors []error
valid_keys := 0
for _, key := range keys_to_poll {
var loadFeed Feed
if err := con.LoadModel(key, &loadFeed); err != nil {
errors = append(errors, err)
} else {
log.Println(loadFeed.Url)
valid_keys++
go func(Url url.URL, inputCh chan<- url.URL) {
inputCh <- Url
}(loadFeed.Url, InputCh)
}
}
for i := 0; i < valid_keys; i++ {
if err := <-OutputCh; err.Err != nil {
errors = append(errors, err)
}
}
if len(errors) != 0 {
log.Println(MultiError(errors))
}
}