本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider.TCPLoadBalancer类的典型用法代码示例。如果您正苦于以下问题:Golang TCPLoadBalancer类的具体用法?Golang TCPLoadBalancer怎么用?Golang TCPLoadBalancer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TCPLoadBalancer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Create
func (sr *ServiceRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
srv := obj.(api.Service)
if srv.ID == "" {
return nil, fmt.Errorf("ID should not be empty: %#v", srv)
}
return apiserver.MakeAsync(func() (interface{}, error) {
// TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers
// correctly no matter what http operations happen.
if srv.CreateExternalLoadBalancer {
var balancer cloudprovider.TCPLoadBalancer
var ok bool
if sr.cloud != nil {
balancer, ok = sr.cloud.TCPLoadBalancer()
}
if ok && balancer != nil {
hosts, err := sr.machines.List()
if err != nil {
return nil, err
}
err = balancer.CreateTCPLoadBalancer(srv.ID, "us-central1", srv.Port, hosts)
if err != nil {
return nil, err
}
} else {
return nil, fmt.Errorf("requested an external service, but no cloud provider supplied.")
}
}
// TODO actually wait for the object to be fully created here.
err := sr.registry.CreateService(srv)
if err != nil {
return nil, err
}
return sr.registry.GetService(srv.ID)
}), nil
}
开发者ID:heyox,项目名称:kubernetes,代码行数:35,代码来源:service_registry.go
示例2: Create
func (sr *ServiceRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
srv := obj.(api.Service)
if errs := api.ValidateService(&srv); len(errs) > 0 {
return nil, fmt.Errorf("Validation errors: %v", errs)
}
return apiserver.MakeAsync(func() (interface{}, error) {
// TODO: Consider moving this to a rectification loop, so that we make/remove external load balancers
// correctly no matter what http operations happen.
if srv.CreateExternalLoadBalancer {
var balancer cloudprovider.TCPLoadBalancer
var zones cloudprovider.Zones
var ok bool
if sr.cloud != nil {
balancer, ok = sr.cloud.TCPLoadBalancer()
if ok {
zones, ok = sr.cloud.Zones()
}
}
if ok && balancer != nil && zones != nil {
hosts, err := sr.machines.List()
if err != nil {
return nil, err
}
zone, err := zones.GetZone()
if err != nil {
return nil, err
}
err = balancer.CreateTCPLoadBalancer(srv.ID, zone, srv.Port, hosts)
if err != nil {
return nil, err
}
} else {
return nil, fmt.Errorf("requested an external service, but no cloud provider supplied.")
}
}
// TODO actually wait for the object to be fully created here.
err := sr.registry.CreateService(srv)
if err != nil {
return nil, err
}
return sr.registry.GetService(srv.ID)
}), nil
}
开发者ID:htomika,项目名称:kubernetes,代码行数:43,代码来源:servicestorage.go
示例3: Delete
func (sr *ServiceRegistryStorage) Delete(id string) (<-chan interface{}, error) {
svc, err := sr.Get(id)
if err != nil {
return nil, err
}
if svc.(*api.Service).CreateExternalLoadBalancer {
var balancer cloudprovider.TCPLoadBalancer
var ok bool
if sr.cloud != nil {
balancer, ok = sr.cloud.TCPLoadBalancer()
}
if ok && balancer != nil {
err = balancer.DeleteTCPLoadBalancer(id, "us-central1")
if err != nil {
return nil, err
}
}
}
return apiserver.MakeAsync(func() interface{} { return apiserver.Status{Success: true} }), sr.registry.DeleteService(id)
}
开发者ID:haegyung,项目名称:kubernetes,代码行数:20,代码来源:service_registry.go
示例4: Create
func (sr *ServiceRegistryStorage) Create(obj interface{}) (<-chan interface{}, error) {
srv := obj.(api.Service)
if srv.CreateExternalLoadBalancer {
var balancer cloudprovider.TCPLoadBalancer
var ok bool
if sr.cloud != nil {
balancer, ok = sr.cloud.TCPLoadBalancer()
}
if ok && balancer != nil {
err := balancer.CreateTCPLoadBalancer(srv.ID, "us-central1", srv.Port, sr.hosts)
if err != nil {
return nil, err
}
} else {
return nil, fmt.Errorf("requested an external service, but no cloud provider supplied.")
}
}
// TODO actually wait for the object to be fully created here.
return apiserver.MakeAsync(func() interface{} { return obj }), sr.registry.CreateService(srv)
}
开发者ID:haegyung,项目名称:kubernetes,代码行数:20,代码来源:service_registry.go
示例5: Delete
func (sr *ServiceRegistryStorage) Delete(id string) error {
svc, err := sr.Get(id)
if err != nil {
return err
}
if svc.(*api.Service).CreateExternalLoadBalancer {
var balancer cloudprovider.TCPLoadBalancer
if sr.cloud != nil {
balancer, err = sr.cloud.TCPLoadBalancer()
if err != nil {
return err
}
}
if balancer != nil {
err = balancer.DeleteTCPLoadBalancer(id, "us-central1")
if err != nil {
return err
}
}
}
return sr.registry.DeleteService(id)
}
开发者ID:r-ling,项目名称:kubernetes,代码行数:22,代码来源:service_registry.go
示例6: Create
func (sr *ServiceRegistryStorage) Create(obj interface{}) error {
srv := obj.(api.Service)
if srv.CreateExternalLoadBalancer {
var balancer cloudprovider.TCPLoadBalancer
if sr.cloud != nil {
var err error
balancer, err = sr.cloud.TCPLoadBalancer()
if err != nil {
return err
}
}
if balancer != nil {
err := balancer.CreateTCPLoadBalancer(srv.ID, "us-central1", srv.Port, sr.hosts)
if err != nil {
return err
}
} else {
return fmt.Errorf("requested an external service, but no cloud provider supplied.")
}
}
return sr.registry.CreateService(srv)
}
开发者ID:r-ling,项目名称:kubernetes,代码行数:22,代码来源:service_registry.go
注:本文中的github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider.TCPLoadBalancer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论