本文整理汇总了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"))
})
})
}