-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add smart retries to table.mutate (#17)
- Loading branch information
1 parent
b85679b
commit e4770e6
Showing
7 changed files
with
422 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- a/node_modules/through2/node_modules/readable-stream/node_modules/process-nextick-args/index.js | ||
+++ b/node_modules/through2/node_modules/readable-stream/node_modules/process-nextick-args/index.js | ||
@@ -5,7 +5,9 @@ if (!process.version || | ||
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { | ||
module.exports = nextTick; | ||
} else { | ||
- module.exports = process.nextTick; | ||
+ module.exports = function() { | ||
+ return process.nextTick.apply(this, arguments); | ||
+ }; | ||
} | ||
|
||
function nextTick(fn, arg1, arg2, arg3) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- a/node_modules/process-nextick-args/index.js | ||
+++ b/node_modules/process-nextick-args/index.js | ||
@@ -5,7 +5,9 @@ if (!process.version || | ||
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { | ||
module.exports = nextTick; | ||
} else { | ||
- module.exports = process.nextTick; | ||
+ module.exports = function() { | ||
+ return process.nextTick.apply(this, arguments); | ||
+ }; | ||
} | ||
|
||
function nextTick(fn, arg1, arg2, arg3) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
{ | ||
"tests": [ | ||
{ | ||
"name": "valid mutation", | ||
"max_retries": 3, | ||
"mutations_request": [ | ||
{ "method": "insert", "key": "foo", "data": {} }, | ||
{ "method": "insert", "key": "bar", "data": {} }, | ||
{ "method": "insert", "key": "baz", "data": {} } | ||
], | ||
"responses": [ | ||
{ "code": 200, "entry_codes": [ 0, 0, 0 ] } | ||
], | ||
"mutation_batches_invoked": [ | ||
[ "foo", "bar", "baz" ] | ||
] | ||
}, { | ||
"name": "retries the failed mutations", | ||
"max_retries": 3, | ||
"mutations_request": [ | ||
{ "method": "insert", "key": "foo", "data": {} }, | ||
{ "method": "insert", "key": "bar", "data": {} }, | ||
{ "method": "insert", "key": "baz", "data": {} } | ||
], | ||
"responses": [ | ||
{ "code": 200, "entry_codes": [ 0, 4, 4 ] }, | ||
{ "code": 200, "entry_codes": [ 4, 0 ] }, | ||
{ "code": 200, "entry_codes": [ 4 ] }, | ||
{ "code": 200, "entry_codes": [ 0 ] } | ||
], | ||
"mutation_batches_invoked": [ | ||
[ "foo", "bar", "baz" ], | ||
[ "bar", "baz" ], | ||
[ "bar" ], | ||
[ "bar" ] | ||
] | ||
}, { | ||
"name": "has a `PartialFailureError` error when an entry fails after the retries", | ||
"max_retries": 3, | ||
"mutations_request": [ | ||
{ "method": "insert", "key": "foo", "data": {} }, | ||
{ "method": "insert", "key": "bar", "data": {} }, | ||
{ "method": "insert", "key": "baz", "data": {} } | ||
], | ||
"responses": [ | ||
{ "code": 200, "entry_codes": [ 0, 4, 0 ] }, | ||
{ "code": 200, "entry_codes": [ 4 ] }, | ||
{ "code": 200, "entry_codes": [ 4 ] }, | ||
{ "code": 200, "entry_codes": [ 4 ] } | ||
], | ||
"mutation_batches_invoked": [ | ||
[ "foo", "bar", "baz" ], | ||
[ "bar" ], | ||
[ "bar" ], | ||
[ "bar" ] | ||
], | ||
"errors": [ | ||
{ "index_in_mutations_request": 1 } | ||
] | ||
}, { | ||
"name": "does not retry unretryable mutations", | ||
"max_retries": 5, | ||
"mutations_request": [ | ||
{ "method": "insert", "key": "foo", "data": {} }, | ||
{ "method": "insert", "key": "bar", "data": {} }, | ||
{ "method": "insert", "key": "baz", "data": {} }, | ||
{ "method": "insert", "key": "qux", "data": {} }, | ||
{ "method": "insert", "key": "quux", "data": {} }, | ||
{ "method": "insert", "key": "corge", "data": {} } | ||
], | ||
"responses": [ | ||
{ "code": 200, "entry_codes": [ 4, 4, 4, 4, 4, 1 ] }, | ||
{ "code": 200, "entry_codes": [ 10, 14, 10, 14, 0 ] }, | ||
{ "code": 200, "entry_codes": [ 1, 4, 4, 0 ] }, | ||
{ "code": 200, "entry_codes": [ 0, 4 ] }, | ||
{ "code": 200, "entry_codes": [ 4 ] }, | ||
{ "code": 200, "entry_codes": [ 1 ] } | ||
], | ||
"mutation_batches_invoked": [ | ||
[ "foo", "bar", "baz", "qux", "quux", "corge" ], | ||
[ "foo", "bar", "baz", "qux", "quux" ], | ||
[ "foo", "bar", "baz", "qux" ], | ||
[ "bar", "baz" ], | ||
[ "baz" ], | ||
[ "baz" ] | ||
], | ||
"errors": [ | ||
{ "index_in_mutations_request": 0 }, | ||
{ "index_in_mutations_request": 2 }, | ||
{ "index_in_mutations_request": 5 } | ||
] | ||
}, { | ||
"name": "considers network errors towards the retry count", | ||
"max_retries": 3, | ||
"mutations_request": [ | ||
{ "method": "insert", "key": "foo", "data": {} }, | ||
{ "method": "insert", "key": "bar", "data": {} }, | ||
{ "method": "insert", "key": "baz", "data": {} } | ||
], | ||
"responses": [ | ||
{ "code": 200, "entry_codes": [ 0, 4, 0 ] }, | ||
{ "code": 429 }, | ||
{ "code": 200, "entry_codes": [ 4 ] }, | ||
{ "code": 200, "entry_codes": [ 4 ] } | ||
], | ||
"mutation_batches_invoked": [ | ||
[ "foo", "bar", "baz" ], | ||
[ "bar" ], | ||
[ "bar" ], | ||
[ "bar" ] | ||
], | ||
"errors": [ | ||
{ "index_in_mutations_request": 1 } | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.