本文整理匯總了Golang中code/cloudfoundry/org/bbs/models.ActualLRP.ActualLRPKey方法的典型用法代碼示例。如果您正苦於以下問題:Golang ActualLRP.ActualLRPKey方法的具體用法?Golang ActualLRP.ActualLRPKey怎麽用?Golang ActualLRP.ActualLRPKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類code/cloudfoundry/org/bbs/models.ActualLRP
的用法示例。
在下文中一共展示了ActualLRP.ActualLRPKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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"))
})
})
}
示例2: EvacuateActualLRP
func (db *SQLDB) EvacuateActualLRP(
logger lager.Logger,
lrpKey *models.ActualLRPKey,
instanceKey *models.ActualLRPInstanceKey,
netInfo *models.ActualLRPNetInfo,
ttl uint64,
) (*models.ActualLRPGroup, error) {
logger = logger.Session("evacuate-lrp", lager.Data{"lrp_key": lrpKey, "instance_key": instanceKey, "net_info": netInfo})
logger.Debug("starting")
defer logger.Debug("complete")
var actualLRP *models.ActualLRP
err := db.transact(logger, func(logger lager.Logger, tx *sql.Tx) error {
var err error
processGuid := lrpKey.ProcessGuid
index := lrpKey.Index
actualLRP, err = db.fetchActualLRPForUpdate(logger, processGuid, index, true, tx)
if err == models.ErrResourceNotFound {
logger.Debug("creating-evacuating-lrp")
actualLRP, err = db.createEvacuatingActualLRP(logger, lrpKey, instanceKey, netInfo, ttl, tx)
return err
}
if err != nil {
logger.Error("failed-locking-lrp", err)
return err
}
if actualLRP.ActualLRPKey.Equal(lrpKey) &&
actualLRP.ActualLRPInstanceKey.Equal(instanceKey) &&
reflect.DeepEqual(actualLRP.ActualLRPNetInfo, *netInfo) {
logger.Debug("evacuating-lrp-already-exists")
return nil
}
now := db.clock.Now().UnixNano()
actualLRP.ModificationTag.Increment()
actualLRP.ActualLRPKey = *lrpKey
actualLRP.ActualLRPInstanceKey = *instanceKey
actualLRP.Since = now
actualLRP.ActualLRPNetInfo = *netInfo
netInfoData, err := db.serializeModel(logger, netInfo)
if err != nil {
logger.Error("failed-serializing-net-info", err)
return err
}
_, err = db.update(logger, tx, "actual_lrps",
SQLAttributes{
"domain": actualLRP.Domain,
"instance_guid": actualLRP.InstanceGuid,
"cell_id": actualLRP.CellId,
"net_info": netInfoData,
"state": actualLRP.State,
"since": actualLRP.Since,
"modification_tag_index": actualLRP.ModificationTag.Index,
},
"process_guid = ? AND instance_index = ? AND evacuating = ?",
actualLRP.ProcessGuid, actualLRP.Index, true,
)
if err != nil {
logger.Error("failed-update-evacuating-lrp", err)
return db.convertSQLError(err)
}
return nil
})
return &models.ActualLRPGroup{Evacuating: actualLRP}, err
}