本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.DesiredLRP.GetDomain方法的典型用法代碼示例。如果您正苦於以下問題:Golang DesiredLRP.GetDomain方法的具體用法?Golang DesiredLRP.GetDomain怎麽用?Golang DesiredLRP.GetDomain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/bbs/models.DesiredLRP
的用法示例。
在下文中一共展示了DesiredLRP.GetDomain方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DesiredLRPs
func (db *ETCDDB) DesiredLRPs(logger lager.Logger, filter models.DesiredLRPFilter) (*models.DesiredLRPs, *models.Error) {
root, bbsErr := db.fetchRecursiveRaw(logger, DesiredLRPSchemaRoot)
if bbsErr.Equal(models.ErrResourceNotFound) {
return &models.DesiredLRPs{}, nil
}
if bbsErr != nil {
return nil, bbsErr
}
if root.Nodes.Len() == 0 {
return &models.DesiredLRPs{}, nil
}
desiredLRPs := models.DesiredLRPs{}
lrpsLock := sync.Mutex{}
var workErr atomic.Value
works := []func(){}
for _, node := range root.Nodes {
node := node
works = append(works, func() {
var lrp models.DesiredLRP
deserializeErr := models.FromJSON([]byte(node.Value), &lrp)
if deserializeErr != nil {
logger.Error("failed-parsing-desired-lrp", deserializeErr)
workErr.Store(fmt.Errorf("cannot parse lrp JSON for key %s: %s", node.Key, deserializeErr.Error()))
return
}
if filter.Domain == "" || lrp.GetDomain() == filter.Domain {
lrpsLock.Lock()
desiredLRPs.DesiredLrps = append(desiredLRPs.DesiredLrps, &lrp)
lrpsLock.Unlock()
}
})
}
throttler, err := workpool.NewThrottler(maxDesiredLRPGetterWorkPoolSize, works)
if err != nil {
logger.Error("failed-constructing-throttler", err, lager.Data{"max-workers": maxDesiredLRPGetterWorkPoolSize, "num-works": len(works)})
return &models.DesiredLRPs{}, models.ErrUnknownError
}
logger.Debug("performing-deserialization-work")
throttler.Work()
if err, ok := workErr.Load().(error); ok {
logger.Error("failed-performing-deserialization-work", err)
return &models.DesiredLRPs{}, models.ErrUnknownError
}
logger.Debug("succeeded-performing-deserialization-work", lager.Data{"num-desired-lrps": len(desiredLRPs.GetDesiredLrps())})
return &desiredLRPs, nil
}