本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/elasticache.ElastiCache.DescribeReplicationGroups方法的典型用法代码示例。如果您正苦于以下问题:Golang ElastiCache.DescribeReplicationGroups方法的具体用法?Golang ElastiCache.DescribeReplicationGroups怎么用?Golang ElastiCache.DescribeReplicationGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aws/aws-sdk-go/service/elasticache.ElastiCache
的用法示例。
在下文中一共展示了ElastiCache.DescribeReplicationGroups方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cacheReplicationGroupStateRefreshFunc
func cacheReplicationGroupStateRefreshFunc(conn *elasticache.ElastiCache, replicationGroupId, givenState string, pending []string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
resp, err := conn.DescribeReplicationGroups(&elasticache.DescribeReplicationGroupsInput{
ReplicationGroupId: aws.String(replicationGroupId),
})
if err != nil {
if eccErr, ok := err.(awserr.Error); ok && eccErr.Code() == "ReplicationGroupNotFoundFault" {
log.Printf("[DEBUG] Replication Group Not Found")
return nil, "", nil
}
log.Printf("[ERROR] cacheClusterReplicationGroupStateRefreshFunc: %s", err)
return nil, "", err
}
if len(resp.ReplicationGroups) == 0 {
return nil, "", fmt.Errorf("[WARN] Error: no Cache Replication Groups found for id (%s)", replicationGroupId)
}
var rg *elasticache.ReplicationGroup
for _, replicationGroup := range resp.ReplicationGroups {
if *replicationGroup.ReplicationGroupId == replicationGroupId {
log.Printf("[DEBUG] Found matching ElastiCache Replication Group: %s", *replicationGroup.ReplicationGroupId)
rg = replicationGroup
}
}
if rg == nil {
return nil, "", fmt.Errorf("[WARN] Error: no matching ElastiCache Replication Group for id (%s)", replicationGroupId)
}
log.Printf("[DEBUG] ElastiCache Replication Group (%s) status: %v", replicationGroupId, *rg.Status)
// return the current state if it's in the pending array
for _, p := range pending {
log.Printf("[DEBUG] ElastiCache: checking pending state (%s) for Replication Group (%s), Replication Group status: %s", pending, replicationGroupId, *rg.Status)
s := *rg.Status
if p == s {
log.Printf("[DEBUG] Return with status: %v", *rg.Status)
return s, p, nil
}
}
return rg, *rg.Status, nil
}
}
示例2: ReplicationGroupStateRefreshFunc
func ReplicationGroupStateRefreshFunc(conn *elasticache.ElastiCache, replicationGroupID, givenState string, pending []string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
resp, err := conn.DescribeReplicationGroups(&elasticache.DescribeReplicationGroupsInput{
ReplicationGroupID: aws.String(replicationGroupID),
})
if err != nil {
ec2err, ok := err.(awserr.Error)
if ok {
log.Printf("[DEBUG] message: %v, code: %v", ec2err.Message(), ec2err.Code())
if ec2err.Code() == "ReplicationGroupNotFoundFault" {
log.Printf("[DEBUG] Detect deletion")
return nil, "", nil
}
}
log.Printf("[ERROR] ReplicationGroupStateRefreshFunc: %s", err)
return nil, "", err
}
c := resp.ReplicationGroups[0]
log.Printf("[DEBUG] status: %v", *c.Status)
// return the current state if it's in the pending array
for _, p := range pending {
s := *c.Status
if p == s {
log.Printf("[DEBUG] Return with status: %v", *c.Status)
return c, p, nil
}
}
// return given state if it's not in pending
if givenState != "" {
return c, givenState, nil
}
log.Printf("[DEBUG] current status: %v", *c.Status)
return c, *c.Status, nil
}
}