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