本文整理汇总了Golang中github.com/CiscoCloud/mesos-consul/state.Task.IP方法的典型用法代码示例。如果您正苦于以下问题:Golang Task.IP方法的具体用法?Golang Task.IP怎么用?Golang Task.IP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/CiscoCloud/mesos-consul/state.Task
的用法示例。
在下文中一共展示了Task.IP方法的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),
})
}
}