本文整理匯總了Golang中github.com/CiscoCloud/mesos-consul/state.Task.Label方法的典型用法代碼示例。如果您正苦於以下問題:Golang Task.Label方法的具體用法?Golang Task.Label怎麽用?Golang Task.Label使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/CiscoCloud/mesos-consul/state.Task
的用法示例。
在下文中一共展示了Task.Label方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: registerTask
func (m *Mesos) registerTask(t *state.Task, agent string) {
var err error
var tags []string
tname := cleanName(t.Name)
address := t.IP("docker", "mesos", "host")
l := t.Label("tags")
if l != "" {
tags = strings.Split(t.Label("tags"), ",")
} else {
tags = []string{}
}
if t.Resources.PortRanges != "" {
for _, port := range t.Resources.Ports() {
err = m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("mesos-consul:%s:%s:%s", agent, tname, port),
Name: tname,
Port: toPort(port),
Address: address,
Tags: tags,
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
Port: port,
}),
Agent: toIP(agent),
})
}
} else {
err = m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("mesos-consul:%s-%s", agent, tname),
Name: tname,
Address: address,
Tags: tags,
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
}),
Agent: toIP(agent),
})
}
if err != nil {
log.Warn(err.Error())
}
}
示例2: registerTask
func (m *Mesos) registerTask(t *state.Task, agent string) {
var tags []string
registered := false
tname := cleanName(t.Name, m.Separator)
log.Debugf("original TaskName : (%v)", tname)
if t.Label("overrideTaskName") != "" {
tname = cleanName(t.Label("overrideTaskName"), m.Separator)
log.Debugf("overrideTaskName to : (%v)", tname)
}
if !m.TaskPrivilege.Allowed(tname) {
// Task not allowed to be registered
return
}
address := t.IP(m.IpOrder...)
l := t.Label("tags")
if l != "" {
tags = strings.Split(t.Label("tags"), ",")
} else {
tags = []string{}
}
tags = buildRegisterTaskTags(tname, tags, m.taskTag)
for key := range t.DiscoveryInfo.Ports.DiscoveryPorts {
var porttags []string
discoveryPort := state.DiscoveryPort(t.DiscoveryInfo.Ports.DiscoveryPorts[key])
serviceName := discoveryPort.Name
servicePort := strconv.Itoa(discoveryPort.Number)
log.Debugf("%+v framework has %+v as a name for %+v port",
t.Name,
discoveryPort.Name,
discoveryPort.Number)
pl := discoveryPort.Label("tags")
if pl != "" {
porttags = strings.Split(discoveryPort.Label("tags"), ",")
} else {
porttags = []string{}
}
if discoveryPort.Name != "" {
m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("%s:%s:%s:%s:%d", m.ServiceIdPrefix, agent, tname, address, discoveryPort.Number),
Name: tname,
Port: toPort(servicePort),
Address: address,
Tags: append(append(tags, serviceName), porttags...),
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
Port: servicePort,
}),
Agent: toIP(agent),
})
registered = true
}
}
if t.Resources.PortRanges != "" {
for _, port := range t.Resources.Ports() {
m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("%s:%s:%s:%s:%s", m.ServiceIdPrefix, agent, tname, address, port),
Name: tname,
Port: toPort(port),
Address: address,
Tags: tags,
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
Port: port,
}),
Agent: toIP(agent),
})
registered = true
}
}
if !registered {
m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("%s:%s-%s:%s", m.ServiceIdPrefix, agent, tname, address),
Name: tname,
Address: address,
Tags: tags,
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
}),
Agent: toIP(agent),
})
}
}
示例3: registerTask
func (m *Mesos) registerTask(t *state.Task, agent string) {
var tags []string
tname := cleanName(t.Name)
address := t.IP(m.IpOrder...)
l := t.Label("tags")
if l != "" {
tags = strings.Split(t.Label("tags"), ",")
} else {
tags = []string{}
}
for key := range t.DiscoveryInfo.Ports.DiscoveryPorts {
discoveryPort := state.DiscoveryPort(t.DiscoveryInfo.Ports.DiscoveryPorts[key])
serviceName := discoveryPort.Name
servicePort := strconv.Itoa(discoveryPort.Number)
log.Debugf("%+v framework has %+v as a name for %+v port",
t.Name,
discoveryPort.Name,
discoveryPort.Number)
if discoveryPort.Name != "" {
m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("mesos-consul:%s:%s:%d", agent, tname, discoveryPort.Number),
Name: tname,
Port: toPort(servicePort),
Address: address,
Tags: []string{serviceName},
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
Port: servicePort,
}),
Agent: toIP(agent),
})
}
}
if t.Resources.PortRanges != "" {
for _, port := range t.Resources.Ports() {
m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("mesos-consul:%s:%s:%s", agent, tname, port),
Name: tname,
Port: toPort(port),
Address: address,
Tags: tags,
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
Port: port,
}),
Agent: toIP(agent),
})
}
} else {
m.Registry.Register(®istry.Service{
ID: fmt.Sprintf("mesos-consul:%s-%s", agent, tname),
Name: tname,
Address: address,
Tags: tags,
Check: GetCheck(t, &CheckVar{
Host: toIP(address),
}),
Agent: toIP(agent),
})
}
}