本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.DesiredLRP.ModificationTag方法的典型用法代碼示例。如果您正苦於以下問題:Golang DesiredLRP.ModificationTag方法的具體用法?Golang DesiredLRP.ModificationTag怎麽用?Golang DesiredLRP.ModificationTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/bbs/models.DesiredLRP
的用法示例。
在下文中一共展示了DesiredLRP.ModificationTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DesireLRP
func (db *SQLDB) DesireLRP(logger lager.Logger, desiredLRP *models.DesiredLRP) error {
logger = logger.WithData(lager.Data{"process_guid": desiredLRP.ProcessGuid})
logger.Info("starting")
defer logger.Info("complete")
return db.transact(logger, func(logger lager.Logger, tx *sql.Tx) error {
routesData, err := json.Marshal(desiredLRP.Routes)
runInfo := desiredLRP.DesiredLRPRunInfo(db.clock.Now())
runInfoData, err := db.serializeModel(logger, &runInfo)
if err != nil {
logger.Error("failed-to-serialize-model", err)
return err
}
volumePlacement := &models.VolumePlacement{}
volumePlacement.DriverNames = []string{}
for _, mount := range desiredLRP.VolumeMounts {
volumePlacement.DriverNames = append(volumePlacement.DriverNames, mount.Driver)
}
volumePlacementData, err := db.serializeModel(logger, volumePlacement)
if err != nil {
logger.Error("failed-to-serialize-model", err)
return err
}
guid, err := db.guidProvider.NextGUID()
if err != nil {
logger.Error("failed-to-generate-guid", err)
return models.ErrGUIDGeneration
}
desiredLRP.ModificationTag = &models.ModificationTag{Epoch: guid, Index: 0}
_, err = db.insert(logger, tx, desiredLRPsTable,
SQLAttributes{
"process_guid": desiredLRP.ProcessGuid,
"domain": desiredLRP.Domain,
"log_guid": desiredLRP.LogGuid,
"annotation": desiredLRP.Annotation,
"instances": desiredLRP.Instances,
"memory_mb": desiredLRP.MemoryMb,
"disk_mb": desiredLRP.DiskMb,
"rootfs": desiredLRP.RootFs,
"volume_placement": volumePlacementData,
"modification_tag_epoch": desiredLRP.ModificationTag.Epoch,
"modification_tag_index": desiredLRP.ModificationTag.Index,
"routes": routesData,
"run_info": runInfoData,
},
)
if err != nil {
logger.Error("failed-inserting-desired", err)
return db.convertSQLError(err)
}
return nil
})
}