Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/async_kinesis_client/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ class DynamoDB:

DEFAULT_MAX_RETRIES = 5

def __init__(self, table_name, shard_id, max_retries=DEFAULT_MAX_RETRIES, host_key=None):
def __init__(self, table, shard_id, max_retries=DEFAULT_MAX_RETRIES, host_key=None):
"""
Initialize DynamoDB
:param table_name: DynamoDB table name
:param table: DynamoDB table object
:param shard_id: ShardId as returned by kinesis client
:param max_retries: Max retries for communicating with DynamoDB
:param host_key: Key to identify reader. If no key provided, defaults to FQDN
"""
self.table_name = table_name
self.shard_id = shard_id
self.shard = {}
self.host_key = host_key or socket.getfqdn()
self.lock_holding_time = None
table = aioboto3.resource('dynamodb').Table(self.table_name)
self.lock_holding_time = 0
self.table_name = table.table_name
self.dynamo_table = RetriableDynamoDB(table=table, retries=max_retries, retry_sleep_time=1)

async def checkpoint(self, seq):
Expand Down
2 changes: 1 addition & 1 deletion src/async_kinesis_client/kinesis_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ async def get_shard_lock(self, shard_id):
# obtain lock if we don't have it, or refresh if we're already holding it
if dynamodb is None:
dynamodb = DynamoDB(
table_name=self.checkpoint_table,
table=self.checkpoint_table,
shard_id=shard_id,
host_key=self.host_key
)
Expand Down