Supply Chain - Data Flow & State Management
Supply Chain (SC) is a data flow and state management architecture.
Table of Content
Idea
- A
nodereceives components from one or moresuppliers. - It produces a
productand delivers it tocustomers. - Doing so complex data flow graphs can be created.
- A supply chain manager
SCMcoordinates the process.
Goals
- ✅ Efficiently manage application state
- ✅ Visualize application data flow & dependencies
- ✅ Smoothly animate state transitions
- ✅ Data caching
- ✅ Prioritze updates
Getting Started
- Checkout the example
- Checkout
node_test.dart - Checkout
scm_test.dart
Features
Effective Asynchronous Workflow
- Our workflow consists of three stages:
Nomination,PreparationandProduction. - In the first stage
nodesarenominatedfor production - The SCM collects nominated nodes for a short time, e.g. a frame or a event loop cycle.
- In the second stage, the SCM
preparesa dependency graph. Nodes arestagedfor production. - In the final step nodes are instructed to
producedepending on dependencies and priorities.
Priorization
- Node can have a
priority. - Nodes with higher priorities are processed first.
- If a node has a high priority, its suppliers will a high priority too.
- Currently a
realtimeand aframepriority is offered. - Nodes with
realtimepriority will produce in the same run loop cycle. - Nodes with
framepriority will produce at the next frame / tick.
Animations
- Scm offers a
tick()method. - Tick will
nominateall nodes withframepriority - These node are instructed to provide a new product on every frame
No Unneccessary Updates
- All products produced by suppliers have a hash
- SCM uses suppliers to estimate if a node needs to produce or not
- No hash changes, no production.
- Additionally SCM builds a dependency graph
Build-In Test Methods
- We break the paradigm not to mix production and test code
- Scm can be set to test mode using the
isTestconstructor param - Use methods like
testRunNormalTasks,testRunFastTasksetc. to control the test flow
Timeout Protection
- I a node does not produce in a given time window, it will be skipped
- Thus nodes cannot block the production process
Visualize the Node Graph
- Use
SupplyChain.graphto get aGraphvizgraph that can be turned into an svg file
Features and bugs
Please file feature requests and bugs at GitHub.