@@ -259,6 +259,45 @@ func (kv dynamodbKV) generatePutItemRequest(key dynamodbKey, data []byte) map[st
259
259
return item
260
260
}
261
261
262
+ type dynamoDbKVWithTimeout struct {
263
+ ddbClient dynamoDbClient
264
+ timeout time.Duration
265
+ }
266
+
267
+ func newDynamoDbKVWithTimeout (client dynamoDbClient , timeout time.Duration ) * dynamoDbKVWithTimeout {
268
+ return & dynamoDbKVWithTimeout {ddbClient : client , timeout : timeout }
269
+ }
270
+
271
+ func (d * dynamoDbKVWithTimeout ) List (ctx context.Context , key dynamodbKey ) ([]string , float64 , error ) {
272
+ ctx , cancel := context .WithTimeout (ctx , d .timeout )
273
+ defer cancel ()
274
+ return d .ddbClient .List (ctx , key )
275
+ }
276
+
277
+ func (d * dynamoDbKVWithTimeout ) Query (ctx context.Context , key dynamodbKey , isPrefix bool ) (map [string ][]byte , float64 , error ) {
278
+ ctx , cancel := context .WithTimeout (ctx , d .timeout )
279
+ defer cancel ()
280
+ return d .ddbClient .Query (ctx , key , isPrefix )
281
+ }
282
+
283
+ func (d * dynamoDbKVWithTimeout ) Delete (ctx context.Context , key dynamodbKey ) error {
284
+ ctx , cancel := context .WithTimeout (ctx , d .timeout )
285
+ defer cancel ()
286
+ return d .ddbClient .Delete (ctx , key )
287
+ }
288
+
289
+ func (d * dynamoDbKVWithTimeout ) Put (ctx context.Context , key dynamodbKey , data []byte ) error {
290
+ ctx , cancel := context .WithTimeout (ctx , d .timeout )
291
+ defer cancel ()
292
+ return d .ddbClient .Put (ctx , key , data )
293
+ }
294
+
295
+ func (d * dynamoDbKVWithTimeout ) Batch (ctx context.Context , put map [dynamodbKey ][]byte , delete []dynamodbKey ) error {
296
+ ctx , cancel := context .WithTimeout (ctx , d .timeout )
297
+ defer cancel ()
298
+ return d .ddbClient .Batch (ctx , put , delete )
299
+ }
300
+
262
301
func generateItemKey (key dynamodbKey ) map [string ]* dynamodb.AttributeValue {
263
302
resp := map [string ]* dynamodb.AttributeValue {
264
303
primaryKey : {
0 commit comments