aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-09-21 19:53:38 +0200
committerFlorian Dold <florian@dold.me>2022-09-21 19:53:38 +0200
commit26cf19ab6c896a299a12605a7b1723540763f52c (patch)
tree98aeb048a3563d69e7307936c906a0b5fe2af06c /packages/taler-wallet-core
parent4fdc00975342636b71a9a62f1335448bf114f038 (diff)
downloadwallet-core-26cf19ab6c896a299a12605a7b1723540763f52c.tar.xz
wallet-cli: add --expect-success flag, exit with error on max retries
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r--packages/taler-wallet-core/src/wallet.ts20
1 files changed, 17 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts
index c91a96841..3ee37ec1a 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -477,6 +477,13 @@ export interface RetryLoopOpts {
stopWhenDone?: boolean;
}
+export interface TaskLoopResult {
+ /**
+ * Was the maximum number of retries exceeded in a task?
+ */
+ retriesExceeded: boolean;
+}
+
/**
* Main retry loop of the wallet.
*
@@ -485,7 +492,8 @@ export interface RetryLoopOpts {
async function runTaskLoop(
ws: InternalWalletState,
opts: RetryLoopOpts = {},
-): Promise<void> {
+): Promise<TaskLoopResult> {
+ let retriesExceeded = false;
for (let iteration = 0; !ws.stopped; iteration++) {
const pending = await getPendingOperations(ws);
logger.trace(`pending operations: ${j2s(pending)}`);
@@ -497,6 +505,7 @@ async function runTaskLoop(
const maxRetries = opts.maxRetries;
if (maxRetries && p.retryInfo && p.retryInfo.retryCounter > maxRetries) {
+ retriesExceeded = true;
logger.warn(
`skipping, as ${maxRetries} retries are exceeded in an operation of type ${p.type}`,
);
@@ -514,7 +523,9 @@ async function runTaskLoop(
if (opts.stopWhenDone && numGivingLiveness === 0 && iteration !== 0) {
logger.warn(`stopping, as no pending operations have lifeness`);
- return;
+ return {
+ retriesExceeded,
+ };
}
// Make sure that we run tasks that don't give lifeness at least
@@ -557,6 +568,9 @@ async function runTaskLoop(
}
}
logger.trace("exiting wallet retry loop");
+ return {
+ retriesExceeded,
+ };
}
/**
@@ -1526,7 +1540,7 @@ export class Wallet {
return runPending(this.ws, forceNow);
}
- runTaskLoop(opts?: RetryLoopOpts): Promise<void> {
+ runTaskLoop(opts?: RetryLoopOpts): Promise<TaskLoopResult> {
return runTaskLoop(this.ws, opts);
}