Dependency Registry
The Dependency Registry is an internal system in Solvix that manages request dependencies.
It tracks requests by their unique identifiers and ensures that dependent requests are executed only after their required dependencies are resolved.
Why Dependency Registry?
When using request dependencies:
- Requests must wait for others to complete
- Execution order must be controlled
- Circular dependencies must be prevented
The registry handles all of this automatically.
How it works
- A request is registered with an
id - The registry stores its promise
- Dependent requests wait for resolution
- Once resolved → dependent requests continue
Basic example
await client.post("/login", {
id: "auth",
});
await client.get("/profile", {
dependsOn: ["auth"],
});
Internal structure (conceptual)
{
id: string,
promise: Promise<any>,
resolve: Function,
reject: Function,
dependsOn?: string[]
}
Execution flow
- Register request in registry
- Check dependencies
- Wait for dependencies
- Execute request
- Resolve or reject
- Notify dependents
Circular dependency detection
Solvix prevents invalid dependency chains.
// Invalid
A depends on B
B depends on A
This is detected and blocked automatically.
Failure handling
If a dependency fails:
- Dependent requests are rejected
- Prevents inconsistent state
Example with multiple dependencies
await client.get("/dashboard", {
dependsOn: ["auth", "settings"],
});
The request runs only after both dependencies complete.
Best practices
- Use unique IDs
- Keep dependency chains shallow
- Avoid unnecessary dependencies
- Use for critical flows only
Summary
The Dependency Registry ensures safe and controlled execution of dependent requests in Solvix.