当前位置: 首页>>代码示例>>Golang>>正文


Golang Transport.LocatorFor方法代码示例

本文整理汇总了Golang中github.com/openshift/geard/transport.Transport.LocatorFor方法的典型用法代码示例。如果您正苦于以下问题:Golang Transport.LocatorFor方法的具体用法?Golang Transport.LocatorFor怎么用?Golang Transport.LocatorFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/openshift/geard/transport.Transport的用法示例。


在下文中一共展示了Transport.LocatorFor方法的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
}
开发者ID:rajatchopra,项目名称:geard,代码行数:11,代码来源:locator.go

示例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
}
开发者ID:rajatchopra,项目名称:geard,代码行数:14,代码来源:locator.go

示例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
}
开发者ID:jcantrill,项目名称:geard,代码行数:14,代码来源:deployment.go

示例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
		}
//.........这里部分代码省略.........
开发者ID:jhadvig,项目名称:geard,代码行数:101,代码来源:deployment.go


注:本文中的github.com/openshift/geard/transport.Transport.LocatorFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。