- Within Forge-world (controlled by Forge's code)
- Within App-world (controlled by app using Forge)
Entry class for Forge. Check Example in README to see how to use it.
Handles the persistence tasks for Forge.
Forge uses Core data for persisting tasks. It sets up the core data stack and gives relevant API to be used by Forge
and ExecutionManager
.
Keeps a reference ot registered Executor
s and handles the execution of tasks.
All failed tasks with retriable errors are persisted by Forge. TaskRetrier checks for tasks that can be retried and executes them.
Defines the abstraction for any work that can be submitted to Forge
.
Produces tasks to be executed and submits it to Forge
.
Handles events to tasks as reported by Forge
.
Executes the Task
.
- App registers Executor
E
for typet
. - Producer submits a task
T
of typet
. - Persistor persists
T
. - ExecutionManager submits
T
toE
. - ChangeManager is informed on all events.
E
callscompletion
with success.- ChangeManager is informed on all events.
- Persistor deletes
T
.
When Executor
is called to execute a Task
, it is passed countOfRetries
. countOfRetries
represents the number of times this task was passed to Executor
.
Executor
based on parameters in Task
, countOfRetries
decides to return any of the following states:
- Success
- Failure. Failure can be of two different kind:
- Retriable
- Non-Retriable
In this case, ChangeManager is NOT told about task completion.
- Conditional retries - based on n/w, disk etc
countOfRetries
is NOT increased.- Consider the scenario of not having network at time of execution.
- You want to retry the task because certain conditions weren't met.
- Non Conditional retries
countOfRetries
IS increased.- Consider that for the network task, server responds with
500
status code and you want to retry after some time.
In this case, ChangeManager IS told about task completion.
- Task failed which can not be retried.
- Consider the case that countOfRetries is now more than 10. You may want to fail the task and show the user error message instead of keeping on trying.
- Remove the task from persistence and fail the task.
Note: Executor is expected to keep a check on countOfRetries and give a Non-Retriable fail at some point. Otherwise the task would forever be stuck in retrying.
Check debugging