• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang kinesis.Kinesis类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/kinesis.Kinesis的典型用法代码示例。如果您正苦于以下问题:Golang Kinesis类的具体用法?Golang Kinesis怎么用?Golang Kinesis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: updateKinesisShardLevelMetrics

func updateKinesisShardLevelMetrics(conn *kinesis.Kinesis, d *schema.ResourceData) error {
	sn := d.Get("name").(string)

	o, n := d.GetChange("shard_level_metrics")
	if o == nil {
		o = new(schema.Set)
	}
	if n == nil {
		n = new(schema.Set)
	}

	os := o.(*schema.Set)
	ns := n.(*schema.Set)

	disableMetrics := os.Difference(ns)
	if disableMetrics.Len() != 0 {
		metrics := disableMetrics.List()
		log.Printf("[DEBUG] Disabling shard level metrics %v for stream %s", metrics, sn)

		props := &kinesis.DisableEnhancedMonitoringInput{
			StreamName:        aws.String(sn),
			ShardLevelMetrics: expandStringList(metrics),
		}

		_, err := conn.DisableEnhancedMonitoring(props)
		if err != nil {
			return fmt.Errorf("Failure to disable shard level metrics for stream %s: %s", sn, err)
		}
		if err := waitForKinesisToBeActive(conn, sn); err != nil {
			return err
		}
	}

	enabledMetrics := ns.Difference(os)
	if enabledMetrics.Len() != 0 {
		metrics := enabledMetrics.List()
		log.Printf("[DEBUG] Enabling shard level metrics %v for stream %s", metrics, sn)

		props := &kinesis.EnableEnhancedMonitoringInput{
			StreamName:        aws.String(sn),
			ShardLevelMetrics: expandStringList(metrics),
		}

		_, err := conn.EnableEnhancedMonitoring(props)
		if err != nil {
			return fmt.Errorf("Failure to enable shard level metrics for stream %s: %s", sn, err)
		}
		if err := waitForKinesisToBeActive(conn, sn); err != nil {
			return err
		}
	}

	return nil
}
开发者ID:Originate,项目名称:terraform,代码行数:54,代码来源:resource_aws_kinesis_stream.go


示例2: setKinesisRetentionPeriod

func setKinesisRetentionPeriod(conn *kinesis.Kinesis, d *schema.ResourceData) error {
	sn := d.Get("name").(string)

	oraw, nraw := d.GetChange("retention_period")
	o := oraw.(int)
	n := nraw.(int)

	if n == 0 {
		log.Printf("[DEBUG] Kinesis Stream (%q) Retention Period Not Changed", sn)
		return nil
	}

	if n > o {
		log.Printf("[DEBUG] Increasing %s Stream Retention Period to %d", sn, n)
		_, err := conn.IncreaseStreamRetentionPeriod(&kinesis.IncreaseStreamRetentionPeriodInput{
			StreamName:           aws.String(sn),
			RetentionPeriodHours: aws.Int64(int64(n)),
		})
		if err != nil {
			return err
		}

	} else {
		log.Printf("[DEBUG] Decreasing %s Stream Retention Period to %d", sn, n)
		_, err := conn.DecreaseStreamRetentionPeriod(&kinesis.DecreaseStreamRetentionPeriodInput{
			StreamName:           aws.String(sn),
			RetentionPeriodHours: aws.Int64(int64(n)),
		})
		if err != nil {
			return err
		}
	}

	stateConf := &resource.StateChangeConf{
		Pending:    []string{"UPDATING"},
		Target:     []string{"ACTIVE"},
		Refresh:    streamStateRefreshFunc(conn, sn),
		Timeout:    5 * time.Minute,
		Delay:      10 * time.Second,
		MinTimeout: 3 * time.Second,
	}

	_, err := stateConf.WaitForState()
	if err != nil {
		return fmt.Errorf(
			"Error waiting for Kinesis Stream (%s) to become active: %s",
			sn, err)
	}

	return nil
}
开发者ID:fromonesrc,项目名称:terraform,代码行数:51,代码来源:resource_aws_kinesis_stream.go


示例3: readKinesisStreamState

func readKinesisStreamState(conn *kinesis.Kinesis, sn string) (kinesisStreamState, error) {
	describeOpts := &kinesis.DescribeStreamInput{
		StreamName: aws.String(sn),
	}

	var state kinesisStreamState
	err := conn.DescribeStreamPages(describeOpts, func(page *kinesis.DescribeStreamOutput, last bool) (shouldContinue bool) {
		state.arn = aws.StringValue(page.StreamDescription.StreamARN)
		state.status = aws.StringValue(page.StreamDescription.StreamStatus)
		state.shardCount += len(page.StreamDescription.Shards)
		return !last
	})
	return state, err
}
开发者ID:autotune,项目名称:terraform,代码行数:14,代码来源:resource_aws_kinesis_stream.go


示例4: DeleteStream

func DeleteStream(service *kinesis.Kinesis, streamName string) {
	params := &kinesis.DeleteStreamInput{
		StreamName: aws.String(streamName),
	}

	resp, err := service.DeleteStream(params)

	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println("Response from deleteStream")
	fmt.Println(resp)

}
开发者ID:luck02,项目名称:goPublish,代码行数:16,代码来源:testHelpers.go


示例5: readKinesisStreamState

func readKinesisStreamState(conn *kinesis.Kinesis, sn string) (kinesisStreamState, error) {
	describeOpts := &kinesis.DescribeStreamInput{
		StreamName: aws.String(sn),
	}

	var state kinesisStreamState
	err := conn.DescribeStreamPages(describeOpts, func(page *kinesis.DescribeStreamOutput, last bool) (shouldContinue bool) {
		state.arn = aws.StringValue(page.StreamDescription.StreamARN)
		state.status = aws.StringValue(page.StreamDescription.StreamStatus)
		state.shardCount += len(openShards(page.StreamDescription.Shards))
		state.retentionPeriod = aws.Int64Value(page.StreamDescription.RetentionPeriodHours)
		state.shardLevelMetrics = flattenKinesisShardLevelMetrics(page.StreamDescription.EnhancedMonitoring)
		return !last
	})
	return state, err
}
开发者ID:Originate,项目名称:terraform,代码行数:16,代码来源:resource_aws_kinesis_stream.go


示例6: setTagsKinesis

// setTags is a helper to set the tags for a resource. It expects the
// tags field to be named "tags"
func setTagsKinesis(conn *kinesis.Kinesis, d *schema.ResourceData) error {

	sn := d.Get("name").(string)

	if d.HasChange("tags") {
		oraw, nraw := d.GetChange("tags")
		o := oraw.(map[string]interface{})
		n := nraw.(map[string]interface{})
		create, remove := diffTagsKinesis(tagsFromMapKinesis(o), tagsFromMapKinesis(n))

		// Set tags
		if len(remove) > 0 {
			log.Printf("[DEBUG] Removing tags: %#v", remove)
			k := make([]*string, len(remove), len(remove))
			for i, t := range remove {
				k[i] = t.Key
			}

			_, err := conn.RemoveTagsFromStream(&kinesis.RemoveTagsFromStreamInput{
				StreamName: aws.String(sn),
				TagKeys:    k,
			})
			if err != nil {
				return err
			}
		}

		if len(create) > 0 {

			log.Printf("[DEBUG] Creating tags: %#v", create)
			t := make(map[string]*string)
			for _, tag := range create {
				t[*tag.Key] = tag.Value
			}

			_, err := conn.AddTagsToStream(&kinesis.AddTagsToStreamInput{
				StreamName: aws.String(sn),
				Tags:       t,
			})
			if err != nil {
				return err
			}
		}
	}

	return nil
}
开发者ID:AssertSelenium,项目名称:terraform,代码行数:49,代码来源:tags_kinesis.go


示例7: CreateStream

func CreateStream(service *kinesis.Kinesis, streamName string) {
	params := &kinesis.CreateStreamInput{
		ShardCount: aws.Int64(1),
		StreamName: aws.String(streamName),
	}

	resp, err := service.CreateStream(params)

	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println("Response from CreateStream:")
	fmt.Println(resp)
	fmt.Println(err)
}
开发者ID:luck02,项目名称:goPublish,代码行数:17,代码来源:testHelpers.go


示例8: streamStateRefreshFunc

func streamStateRefreshFunc(conn *kinesis.Kinesis, sn string) resource.StateRefreshFunc {
	return func() (interface{}, string, error) {
		describeOpts := &kinesis.DescribeStreamInput{
			StreamName: aws.String(sn),
		}
		resp, err := conn.DescribeStream(describeOpts)
		if err != nil {
			if awsErr, ok := err.(awserr.Error); ok {
				if awsErr.Code() == "ResourceNotFoundException" {
					return 42, "DESTROYED", nil
				}
				return nil, awsErr.Code(), err
			}
			return nil, "failed", err
		}

		return resp.StreamDescription, *resp.StreamDescription.StreamStatus, nil
	}
}
开发者ID:saulshanabrook,项目名称:terraform,代码行数:19,代码来源:resource_aws_kinesis_stream.go


示例9: CheckStreamStatus

func CheckStreamStatus(status string, service *kinesis.Kinesis, streamName string) bool {

	descParams := &kinesis.DescribeStreamInput{
		StreamName: aws.String(streamName),
	}

	for i := 0; i < 30; i++ {
		respDescribe, err := service.DescribeStream(descParams)

		if *respDescribe.StreamDescription.StreamStatus == status {
			return true
		}
		fmt.Println(respDescribe)
		fmt.Println(err)

		time.Sleep(500 * time.Millisecond)

	}

	return false
}
开发者ID:luck02,项目名称:goPublish,代码行数:21,代码来源:testHelpers.go


示例10: setKinesisRetentionPeriod

func setKinesisRetentionPeriod(conn *kinesis.Kinesis, d *schema.ResourceData) error {
	sn := d.Get("name").(string)

	oraw, nraw := d.GetChange("retention_period")
	o := oraw.(int)
	n := nraw.(int)

	if n == 0 {
		log.Printf("[DEBUG] Kinesis Stream (%q) Retention Period Not Changed", sn)
		return nil
	}

	if n > o {
		log.Printf("[DEBUG] Increasing %s Stream Retention Period to %d", sn, n)
		_, err := conn.IncreaseStreamRetentionPeriod(&kinesis.IncreaseStreamRetentionPeriodInput{
			StreamName:           aws.String(sn),
			RetentionPeriodHours: aws.Int64(int64(n)),
		})
		if err != nil {
			return err
		}

	} else {
		log.Printf("[DEBUG] Decreasing %s Stream Retention Period to %d", sn, n)
		_, err := conn.DecreaseStreamRetentionPeriod(&kinesis.DecreaseStreamRetentionPeriodInput{
			StreamName:           aws.String(sn),
			RetentionPeriodHours: aws.Int64(int64(n)),
		})
		if err != nil {
			return err
		}
	}

	if err := waitForKinesisToBeActive(conn, sn); err != nil {
		return err
	}

	return nil
}
开发者ID:Originate,项目名称:terraform,代码行数:39,代码来源:resource_aws_kinesis_stream.go



注:本文中的github.com/aws/aws-sdk-go/service/kinesis.Kinesis类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang kms.New函数代码示例发布时间:2022-05-24
下一篇:
Golang kinesis.New函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap