本文整理匯總了Golang中github.com/mesos/mesos-go/mesosproto.Offer.GetAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Offer.GetAttributes方法的具體用法?Golang Offer.GetAttributes怎麽用?Golang Offer.GetAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mesos/mesos-go/mesosproto.Offer
的用法示例。
在下文中一共展示了Offer.GetAttributes方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Match
func (c *EqualsConstraint) Match(offer *mesos.Offer) bool {
for _, a := range offer.GetAttributes() {
if c.Attribute == a.GetName() {
if a.GetType() == mesos.Value_TEXT {
return c.Value == a.GetText().GetValue()
} else if a.GetType() == mesos.Value_SCALAR {
return c.Value == fmt.Sprintf("%.f", a.GetScalar().GetValue())
} else {
return false
}
}
}
return false
}
示例2: OfferAttributes
func OfferAttributes(offer *mesos.Offer) map[string]string {
offerAttributes := map[string]string{
"hostname": offer.GetHostname(),
}
for _, attribute := range offer.GetAttributes() {
text := attribute.GetText().GetValue()
if text != "" {
offerAttributes[attribute.GetName()] = text
}
}
return offerAttributes
}
示例3: Offer
func Offer(offer *mesos.Offer) string {
var buffer bytes.Buffer
buffer.WriteString(offer.GetHostname())
buffer.WriteString(ID(offer.GetId().GetValue()))
resources := Resources(offer.GetResources())
if resources != "" {
buffer.WriteString(" ")
buffer.WriteString(resources)
}
attributes := Attributes(offer.GetAttributes())
if attributes != "" {
buffer.WriteString(" ")
buffer.WriteString(attributes)
}
return buffer.String()
}
示例4: offerString
func offerString(offer *mesos.Offer) string {
return fmt.Sprintf("\n%s%s %s %s", offer.GetHostname(), idString(offer.GetId().GetValue()), resourcesString(offer.GetResources()), attributesString(offer.GetAttributes()))
}