github.com/kardianos/nomad@v0.1.3-0.20151022182107-b13df73ee850/api/constraint.go (about)

     1  package api
     2  
     3  // Constraint is used to serialize a job placement constraint.
     4  type Constraint struct {
     5  	Hard    bool
     6  	LTarget string
     7  	RTarget string
     8  	Operand string
     9  	Weight  int
    10  }
    11  
    12  // HardConstraint is used to create a new hard constraint.
    13  func HardConstraint(left, operand, right string) *Constraint {
    14  	return constraint(left, operand, right, true, 0)
    15  }
    16  
    17  // SoftConstraint is used to create a new soft constraint. It
    18  // takes an additional weight parameter to allow balancing
    19  // multiple soft constraints amongst eachother.
    20  func SoftConstraint(left, operand, right string, weight int) *Constraint {
    21  	return constraint(left, operand, right, false, weight)
    22  }
    23  
    24  // constraint generates a new job placement constraint.
    25  func constraint(left, operand, right string, hard bool, weight int) *Constraint {
    26  	return &Constraint{
    27  		Hard:    hard,
    28  		LTarget: left,
    29  		RTarget: right,
    30  		Operand: operand,
    31  		Weight:  weight,
    32  	}
    33  }