本文整理匯總了Golang中github.com/NetSys/quilt/db.Database.SelectFromPlacement方法的典型用法代碼示例。如果您正苦於以下問題:Golang Database.SelectFromPlacement方法的具體用法?Golang Database.SelectFromPlacement怎麽用?Golang Database.SelectFromPlacement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/NetSys/quilt/db.Database
的用法示例。
在下文中一共展示了Database.SelectFromPlacement方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: updatePlacements
func updatePlacements(view db.Database, spec stitch.Stitch) {
stitchPlacements := toDBPlacements(spec.QueryPlacements())
key := func(val interface{}) interface{} {
pVal := val.(db.Placement)
return struct {
tl string
rule db.PlacementRule
}{pVal.TargetLabel, pVal.Rule}
}
_, addSet, removeSet := join.HashJoin(stitchPlacements,
db.PlacementSlice(view.SelectFromPlacement(nil)), key, key)
for _, toAddIntf := range addSet {
toAdd := toAddIntf.(db.Placement)
newPlacement := view.InsertPlacement()
newPlacement.TargetLabel = toAdd.TargetLabel
newPlacement.Rule = toAdd.Rule
view.Commit(newPlacement)
}
for _, toRemove := range removeSet {
view.Remove(toRemove.(db.Placement))
}
}
示例2: updatePlacements
func updatePlacements(view db.Database, spec stitch.Stitch) {
var placements db.PlacementSlice
for _, sp := range spec.Placements {
placements = append(placements, db.Placement{
TargetLabel: sp.TargetLabel,
Exclusive: sp.Exclusive,
OtherLabel: sp.OtherLabel,
Provider: sp.Provider,
Size: sp.Size,
Region: sp.Region,
})
}
key := func(val interface{}) interface{} {
p := val.(db.Placement)
p.ID = 0
return p
}
dbPlacements := db.PlacementSlice(view.SelectFromPlacement(nil))
_, addSet, removeSet := join.HashJoin(placements, dbPlacements, key, key)
for _, toAddIntf := range addSet {
toAdd := toAddIntf.(db.Placement)
id := view.InsertPlacement().ID
toAdd.ID = id
view.Commit(toAdd)
}
for _, toRemove := range removeSet {
view.Remove(toRemove.(db.Placement))
}
}
示例3: placeContainers
func placeContainers(view db.Database) {
constraints := view.SelectFromPlacement(nil)
containers := view.SelectFromContainer(nil)
minions := view.SelectFromMinion(nil)
ctx := makeContext(minions, constraints, containers)
cleanupPlacements(ctx)
placeUnassigned(ctx)
for _, change := range ctx.changed {
view.Commit(*change)
}
}