【问题标题】:Boto3 read from Kinesis stream at timestampBoto3 在时间戳从 Kinesis 流中读取
【发布时间】:2016-05-17 10:06:21
【问题描述】:

我正在尝试从 Kinesis 流中读取数据。如果我使用ShardIteratorTypeAT_SEQUENCE_NUMBERLATEST,它工作正常。但是,如果我尝试使用 AT_TIMESTAMP 类型并设置 TIMESTAMP,boto3 会抱怨:

  File "/usr/local/lib/python2.7/site-packages/botocore/validate.py", line 269, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "Timestamp", must be one of: StreamName, ShardId, ShardIteratorType, StartingSequenceNumber

获取shard_id的代码如下。

import boto3
from datetime import datetime

client = boto3.client('kinesis')

shard_it = client.get_shard_iterator(
    StreamName='foo',
    ShardId='shardId-000000000000',
    ShardIteratorType='AT_TIMESTAMP',
    Timestamp=datetime(2015, 1, 1)
)

有人有这方面的经验吗?

根据API docs参数存在。

【问题讨论】:

  • 再想一想,您的 boto3 似乎不是最新的。请运行 $ sudo pip install -U boto3.
  • 谢谢@quiver!原因是我的boto3 版本已经过时了。我传递的时间戳是有效的。随意编辑您的答案,我会接受。
  • @ustroetz 更新了答案!很高兴你做到了。

标签: python boto3 amazon-kinesis


【解决方案1】:

您的 boto3 似乎不是最新的,因此 boto3 客户端库无法识别新参数。请运行$ sudo pip install -u boto3 之类的。

顺便说一下,Timestamp 参数接受以下两个:

  • 日期时间对象(例如datetime.datetime
  • UNIX 时间戳(例如time.time

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-11
    • 2019-09-10
    • 1970-01-01
    • 2021-12-11
    • 2021-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多