本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.ActualLRP.ActualLRPKey方法的典型用法代碼示例。如果您正苦於以下問題:Golang ActualLRP.ActualLRPKey方法的具體用法?Golang ActualLRP.ActualLRPKey怎麽用?Golang ActualLRP.ActualLRPKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/bbs/models.ActualLRP
的用法示例。
在下文中一共展示了ActualLRP.ActualLRPKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: EvacuateActualLRP
func (db *ETCDDB) EvacuateActualLRP(
logger lager.Logger,
lrpKey *models.ActualLRPKey,
instanceKey *models.ActualLRPInstanceKey,
netInfo *models.ActualLRPNetInfo,
ttl uint64,
) (*models.ActualLRPGroup, error) {
logger = logger.Session("evacuate-actual-lrp", lager.Data{"process_guid": lrpKey.ProcessGuid, "index": lrpKey.Index})
logger.Debug("starting")
defer logger.Debug("complete")
node, err := db.fetchRaw(logger, EvacuatingActualLRPSchemaPath(lrpKey.ProcessGuid, lrpKey.Index))
bbsErr := models.ConvertError(err)
if bbsErr != nil {
if bbsErr.Type == models.Error_ResourceNotFound {
return db.createEvacuatingActualLRP(logger, lrpKey, instanceKey, netInfo, ttl)
}
return nil, bbsErr
}
lrp := models.ActualLRP{}
err = db.deserializeModel(logger, node, &lrp)
if err != nil {
return nil, err
}
if lrp.ActualLRPKey.Equal(lrpKey) &&
lrp.ActualLRPInstanceKey.Equal(instanceKey) &&
reflect.DeepEqual(lrp.ActualLRPNetInfo, *netInfo) {
return &models.ActualLRPGroup{Evacuating: &lrp}, nil
}
lrp.ActualLRPNetInfo = *netInfo
lrp.ActualLRPKey = *lrpKey
lrp.ActualLRPInstanceKey = *instanceKey
lrp.Since = db.clock.Now().UnixNano()
lrp.ModificationTag.Increment()
data, err := db.serializeModel(logger, &lrp)
if err != nil {
logger.Error("failed-serializing", err)
return nil, err
}
_, err = db.client.CompareAndSwap(EvacuatingActualLRPSchemaPath(lrp.ProcessGuid, lrp.Index), data, ttl, node.ModifiedIndex)
if err != nil {
return nil, ErrorFromEtcdError(logger, err)
}
return &models.ActualLRPGroup{Evacuating: &lrp}, nil
}
示例2: itValidatesPresenceOfTheLRPKey
func itValidatesPresenceOfTheLRPKey(lrp *models.ActualLRP) {
Context("when the lrp key is set", func() {
BeforeEach(func() {
lrp.ActualLRPKey = models.NewActualLRPKey("some-guid", 1, "domain")
})
It("validate does not return an error", func() {
Expect(lrp.Validate()).NotTo(HaveOccurred())
})
})
Context("when the lrp key is not set", func() {
BeforeEach(func() {
lrp.ActualLRPKey = models.ActualLRPKey{}
})
It("validate returns an error", func() {
err := lrp.Validate()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("process_guid"))
})
})
}