Updated on 2023-06-21 GMT+08:00

Obtaining a Data Cursor

Initialize a DIS SDK client instance as instructed in Initializing a DIS SDK Client Instance.

Configure the following parameters:

partitionId="shardId-0000000000"  
streamname ="dis-test1"  #Name of an existing stream.
Configure the five cursors as follows:
# startSeq and AT_SEQUENCE_NUMBER/AFTER_SEQUENCE_NUMBER are used together.
r = cli.getCursor(streamname, partitionId, cursorType='AT_SEQUENCE_NUMBER', startSeq="0")
# r = cli.getCursor(streamname, partitionId, cursorType='AFTER_SEQUENCE_NUMBER', startSeq="0")
# timestamp and AT_TIMESTAMP are used together.
# r = cli.getCursor(streamname, partitionId, cursorType='AT_TIMESTAMP',timestamp=1554694135190)
# r = cli.getCursor(streamname, partitionId, cursorType='TRIM_HORIZON')
# r = cli.getCursor(streamname, partitionId, cursorType='LATEST')

After configuring the parameters, run the getCursor_sample.py file to call getCursor_test. The following is an example response:

1
2
200
{"partition_cursor": "eyJnZXRJdGVyYXRvclBhcmFtIjp7InN0cmVhbS1uYW1lIjoiSCIsInBhcnRpdGlvbi1pZCI6InNoYXJkSWQtMDAwMDAwMDAwMCIsImN1cnNvci10eXBlIjoiQVRfU0VRVUVOQ0VfTlVNQkVSIiwic3RhcnRpbmctc2VxdWVuY2UtbnVtYmVyIjoiMCJ9LCJnZW5lcmF0ZVRpbWVzdGFtcCI6MTUzMjQyNDg4NzE1NH0"}