本文整理匯總了Golang中github.com/dmaze/goordinate/coordinate.WorkUnit.SetPriority方法的典型用法代碼示例。如果您正苦於以下問題:Golang WorkUnit.SetPriority方法的具體用法?Golang WorkUnit.SetPriority怎麽用?Golang WorkUnit.SetPriority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dmaze/goordinate/coordinate.WorkUnit
的用法示例。
在下文中一共展示了WorkUnit.SetPriority方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestWorkUnitPrioritySet
// TestWorkUnitPrioritySet tests two different ways of setting work unit
// priority.
func (s *Suite) TestWorkUnitPrioritySet(c *check.C) {
var (
err error
priority float64
unit coordinate.WorkUnit
)
spec, worker := s.makeWorkSpecAndWorker(c)
unit, err = spec.AddWorkUnit("a", map[string]interface{}{}, 0.0)
c.Assert(err, check.IsNil)
priority, err = unit.Priority()
c.Assert(err, check.IsNil)
c.Check(priority, check.Equals, 0.0)
unit, err = spec.AddWorkUnit("b", map[string]interface{}{}, 0.0)
c.Assert(err, check.IsNil)
err = unit.SetPriority(10.0)
c.Assert(err, check.IsNil)
priority, err = unit.Priority()
c.Assert(err, check.IsNil)
c.Check(priority, check.Equals, 10.0)
unit, err = spec.AddWorkUnit("c", map[string]interface{}{}, 0.0)
c.Assert(err, check.IsNil)
err = spec.SetWorkUnitPriorities(coordinate.WorkUnitQuery{
Names: []string{"c"},
}, 20.0)
c.Assert(err, check.IsNil)
priority, err = unit.Priority()
c.Assert(err, check.IsNil)
c.Check(priority, check.Equals, 20.0)
unit, err = spec.AddWorkUnit("d", map[string]interface{}{}, 0.0)
c.Assert(err, check.IsNil)
err = spec.AdjustWorkUnitPriorities(coordinate.WorkUnitQuery{
Names: []string{"d"},
}, 20.0)
priority, err = unit.Priority()
c.Assert(err, check.IsNil)
c.Check(priority, check.Equals, 20.0)
c.Assert(err, check.IsNil)
err = spec.AdjustWorkUnitPriorities(coordinate.WorkUnitQuery{
Names: []string{"d"},
}, 10.0)
c.Assert(err, check.IsNil)
priority, err = unit.Priority()
c.Assert(err, check.IsNil)
c.Check(priority, check.Equals, 30.0)
unit, err = spec.WorkUnit("b")
c.Assert(err, check.IsNil)
priority, err = unit.Priority()
c.Assert(err, check.IsNil)
c.Check(priority, check.Equals, 10.0)
checkWorkUnitOrder(c, worker, spec, "d", "c", "b", "a")
}