當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。