-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathkinesis.py
More file actions
36 lines (30 loc) · 1.01 KB
/
kinesis.py
File metadata and controls
36 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from time import sleep
import boto3
import threading
client = boto3.client('kinesis')
def consume(stream_name:str='ora.ADMIN.CUSTOMERS'):
shards = client.list_shards(StreamName=stream_name)
# print(f'shards {shards}========{dir(shards)}')
for shard in shards['Shards']:
# print(f'shard {shard["ShardId"]}')
si = client.get_shard_iterator(
StreamName=stream_name,
ShardId=shard["ShardId"],
ShardIteratorType='LATEST'
)
response = client.get_records(ShardIterator=si['ShardIterator'])
for rec in response['Records']:
print(rec)
# threading.Thread(target=lambda: show(si)).start()
def show(si):
i = si['ShardIterator']
while i is not None:
response = client.get_records(ShardIterator=i)
for rec in response['Records']:
print(rec)
sleep(10)
i = response['NextShardIterator']
if __name__ == "__main__":
while True:
consume()
sleep(10)