本文整理汇总了Golang中github.com/CiscoCloud/mesos-consul/state.Task类的典型用法代码示例。如果您正苦于以下问题:Golang Task类的具体用法?Golang Task怎么用?Golang Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Task类的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())
}
}
开发者ID:micahlmartin,项目名称:mesos-consul,代码行数:47,代码来源:register.go
示例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),
})
}
}
开发者ID:a-nldisr,项目名称:mesos-consul,代码行数:90,代码来源:register.go
示例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),
})
}
}
开发者ID:jnonon,项目名称:mesos-consul,代码行数:66,代码来源:register.go
注:本文中的github.com/CiscoCloud/mesos-consul/state.Task类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论