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


Golang ManagementAPI.AddRoleEndpoints方法代码示例

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


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

示例1: openEndpoints

// openEndpoints opens the endpoints in the Azure deployment.
func (azInstance *azureInstance) openEndpoints(api *gwacl.ManagementAPI, portRanges []network.PortRange) error {
	request := &gwacl.AddRoleEndpointsRequest{
		ServiceName:    azInstance.serviceName(),
		DeploymentName: azInstance.deploymentName,
		RoleName:       azInstance.roleName,
	}
	for _, portRange := range portRanges {
		name := fmt.Sprintf("%s%d-%d", portRange.Protocol, portRange.FromPort, portRange.ToPort)
		for port := portRange.FromPort; port <= portRange.ToPort; port++ {
			endpoint := gwacl.InputEndpoint{
				LocalPort: port,
				Name:      fmt.Sprintf("%s_range_%d", name, port),
				Port:      port,
				Protocol:  portRange.Protocol,
			}
			if azInstance.supportsLoadBalancing() {
				probePort := port
				if strings.ToUpper(endpoint.Protocol) == "UDP" {
					// Load balancing needs a TCP port to probe, or an HTTP
					// server port & path to query. For UDP, we just use the
					// machine's SSH agent port to test machine liveness.
					//
					// It probably doesn't make sense to load balance most UDP
					// protocols transparently, but that's an application level
					// concern.
					probePort = 22
				}
				endpoint.LoadBalancedEndpointSetName = name
				endpoint.LoadBalancerProbe = &gwacl.LoadBalancerProbe{
					Port:     probePort,
					Protocol: "TCP",
				}
			}
			request.InputEndpoints = append(request.InputEndpoints, endpoint)
		}
	}
	return api.AddRoleEndpoints(request)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:39,代码来源:instance.go


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