Skip to content

Commit

Permalink
[webhooks] refactor retry condition
Browse files Browse the repository at this point in the history
  • Loading branch information
capcom6 committed Jun 24, 2024
1 parent 33c0319 commit 453772c
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class SendWebhookWorker(appContext: Context, params: WorkerParameters) :

override suspend fun doWork(): Result {
try {
if (runAttemptCount > MAX_RETRIES) {
return Result.failure()
}

val url = inputData.getString(INPUT_URL) ?: return Result.failure()
val data = inputData.getString(INPUT_DATA)
?.let { gson.fromJson(it, JsonObject::class.java) }
Expand All @@ -59,10 +63,7 @@ class SendWebhookWorker(appContext: Context, params: WorkerParameters) :
return Result.failure()
} catch (e: Throwable) {
e.printStackTrace()
return when (runAttemptCount >= MAX_RETRIES) {
false -> Result.retry()
else -> Result.failure()
}
return Result.retry()
} finally {
client.close()
}
Expand Down

0 comments on commit 453772c

Please sign in to comment.