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


Golang v1.BackendService类代码示例

本文整理汇总了Golang中google/golang.org/api/compute/v1.BackendService的典型用法代码示例。如果您正苦于以下问题:Golang BackendService类的具体用法?Golang BackendService怎么用?Golang BackendService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BackendService类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: edgeHop

// edgeHop checks the links of the given backend by executing an edge hop.
// It fixes broken links.
func (b *Backends) edgeHop(be *compute.BackendService, igs []*compute.InstanceGroup) error {
	beIGs := sets.String{}
	for _, beToIG := range be.Backends {
		beIGs.Insert(beToIG.Group)
	}
	igLinks := sets.String{}
	for _, igToBE := range igs {
		igLinks.Insert(igToBE.SelfLink)
	}
	if beIGs.IsSuperset(igLinks) {
		return nil
	}
	glog.Infof("Backend %v has a broken edge, expected igs %+v, current igs %+v",
		be.Name, igLinks.List(), beIGs.List())

	newBackends := []*compute.Backend{}
	for _, b := range getBackendsForIGs(igs) {
		if !beIGs.Has(b.Group) {
			newBackends = append(newBackends, b)
		}
	}
	be.Backends = append(be.Backends, newBackends...)
	if err := b.cloud.UpdateBackendService(be); err != nil {
		return err
	}
	return nil
}
开发者ID:upmc-enterprises,项目名称:contrib,代码行数:29,代码来源:backends.go

示例2: edgeHop

// edgeHop checks the links of the given backend by executing an edge hop.
// It fixes broken links.
func (b *Backends) edgeHop(be *compute.BackendService, ig *compute.InstanceGroup) error {
	if len(be.Backends) == 1 &&
		compareLinks(be.Backends[0].Group, ig.SelfLink) {
		return nil
	}
	glog.Infof("Backend %v has a broken edge, adding link to %v",
		be.Name, ig.Name)
	be.Backends = []*compute.Backend{
		{Group: ig.SelfLink},
	}
	if err := b.cloud.UpdateBackendService(be); err != nil {
		return err
	}
	return nil
}
开发者ID:humanconditionsafety,项目名称:contrib,代码行数:17,代码来源:backends.go

示例3: edgeHop

// edgeHop checks the links of the given backend by executing an edge hop.
// It fixes broken links.
func (b *Backends) edgeHop(be *compute.BackendService, igs []*compute.InstanceGroup) error {
	beIGs := sets.String{}
	for _, beToIG := range be.Backends {
		beIGs.Insert(beToIG.Group)
	}
	igLinks := sets.String{}
	for _, igToBE := range igs {
		igLinks.Insert(igToBE.SelfLink)
	}
	if igLinks.Equal(beIGs) {
		return nil
	}
	glog.Infof("Backend %v has a broken edge, expected igs %+v, current igs %+v",
		be.Name, igLinks.List(), beIGs.List())
	be.Backends = getBackendsForIGs(igs)
	if err := b.cloud.UpdateBackendService(be); err != nil {
		return err
	}
	return nil
}
开发者ID:raggi,项目名称:contrib,代码行数:22,代码来源:backends.go

示例4: CreateBackendService

// CreateBackendService fakes backend service creation.
func (f *FakeBackendServices) CreateBackendService(be *compute.BackendService) error {
	f.calls = append(f.calls, utils.Create)
	be.SelfLink = be.Name
	f.backendServices = append(f.backendServices, be)
	return nil
}
开发者ID:jojimt,项目名称:contrib,代码行数:7,代码来源:fakes.go


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