本文整理汇总了Golang中github.com/openshift/geard/transport.Transport类的典型用法代码示例。如果您正苦于以下问题:Golang Transport类的具体用法?Golang Transport怎么用?Golang Transport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transport类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewHostLocators
func NewHostLocators(t transport.Transport, values ...string) (Locators, error) {
out := make(Locators, 0, len(values))
for i := range values {
r, err := t.LocatorFor(values[i])
if err != nil {
return out, err
}
out = append(out, &ResourceLocator{"", "", r})
}
return out, nil
}
示例2: NewResourceLocator
func NewResourceLocator(t transport.Transport, defaultType ResourceType, value string) (Locator, error) {
res, host, id, errs := SplitTypeHostSuffix(value)
if errs != nil {
return nil, errs
}
if res == "" {
res = defaultType
}
locator, err := t.LocatorFor(host)
if err != nil {
return nil, err
}
return &ResourceLocator{ResourceType(res), id, locator}, nil
}
示例3: LocatorsForDeploymentInstances
func LocatorsForDeploymentInstances(t transport.Transport, instances deployment.InstanceRefs) (cmd.Locators, error) {
locators := make(cmd.Locators, 0, len(instances))
for _, instance := range instances {
if instance.On != nil {
locator, err := t.LocatorFor(*instance.On)
if err != nil {
return cmd.Locators{}, err
}
resource := &cmd.ResourceLocator{cloc.ResourceTypeContainer, string(instance.Id), locator}
locators = append(locators, resource)
}
}
return locators, nil
}
示例4: Describe
func (d Deployment) Describe(placement PlacementStrategy, t transport.Transport) (next *Deployment, removed InstanceRefs, err error) {
// copy the container list and clear any intermediate state
sources := d.Containers.Copy()
// assign instances to containers or the remove list
for i := range d.Instances {
instance := &d.Instances[i]
copied := *instance
// is the instance invalid or no longer part of the cluster
if instance.On == nil {
continue
}
if instance.on == nil {
locator, errl := t.LocatorFor(*instance.On)
if errl != nil {
err = errors.New(fmt.Sprintf("The host %s for instance %s is not recognized - you may be using a different transport than originally specified: %s", *instance.On, instance.Id, errl.Error()))
return
}
instance.on = locator
}
if placement.RemoveFromLocation(instance.on) {
removed = append(removed, &copied)
continue
}
// locate the container
c, found := sources.Find(instance.From)
if !found {
removed = append(removed, &copied)
continue
}
c.AddInstance(&copied)
}
// create new instances for each container
added := make(InstanceRefs, 0)
for i := range sources {
c := &sources[i]
if errc := d.createInstances(c); errc != nil {
err = errc
return
}
for j := range c.instances {
if c.instances[j].add {
added = append(added, c.instances[j])
}
}
}
// assign to hosts
errp := placement.Assign(added, sources)
if errp != nil {
err = errp
return
}
// cull any instances flagged for removal and enforce upper limits
for i := range sources {
for _, instance := range sources[i].Instances() {
if instance.On == nil && !instance.remove {
err = errors.New("deployment: one or more instances were not assigned to a host")
return
}
}
removed = append(removed, sources[i].trimInstances()...)
}
// check for basic link consistency and ordering
links, erro := sources.OrderLinks()
if erro != nil {
err = erro
return
}
// expose ports for all links
for i := range links {
if erre := links[i].exposePorts(); erre != nil {
err = erre
return
}
}
// load and reserve all ports
table, errn := NewInstancePortTable(sources)
if errn != nil {
err = errn
return
}
for i := range links {
if errr := links[i].reserve(table); errr != nil {
err = errr
return
}
}
// generate the links
for i := range links {
if erra := links[i].appendLinks(); erra != nil {
err = erra
return
}
//.........这里部分代码省略.........