Dependencies are used to allow components to react to the availability or unavailability of other components in Piped.
The dependency manager adds the dependencies to a dependency graph. A dependency graph is a directed, acyclic graph (DAG) of IDependency instances.
Whenever a dependency fires it on_ready or on_lost event, the dependency manager find the consumers of the dependency in the dependency graph and propagates is to the consumers on_dependency_ready or on_dependency_lost event accordingly.
The default IDependency implementations calls the on_ready event when all of their dependencies are available (or the on_lost event when one of its dependencies are lost).
This results in the cascading of dependency availabilities. Consider the following dependency graph:
If d becomes becomes unavailable, the graph would become:
Whenever d becomes available again, the on_ready events will cascade similarly, and the dependency graph will return to its former state.
Before a dependency can be used and before its on_ready and on_lost are cascaded to its consumers, it needs to be resolved.
When a dependency is resolved, it determines its initial state and fires either its on_ready or on_lost event. When the dependency resolves, it becomes eligible to receive events from its own dependencies and is enable to react to these.
In order to react to the availability of dependencies, IDependency defines two events, on_ready, on_lost.