github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/design/projectors/lazy-projections.md (about) 1 # Terms 2 - Lazy Projection - a projection which is kept non-generated upon request. When requested, the projection is initialized using WLog, and then kept updated from PLog. 3 - Dynamic Projection - a projection which is updated with every PLog event (e.g. Table). 4 5 # Projections 6 7 ```mermaid 8 erDiagram 9 Projector ||--|| Projection: generates 10 Projection ||--|| LazyProjection: "can be" 11 Projection ||--|| DynamicProjection: "can be" 12 DynamicProjection ||--|| Actualizer: "fed by" 13 Projection_Status_Raw ||--|| RawActualizer: "fed by" 14 RawActualizer ||--|| WLog: "reads from" 15 Trigger ||--|| Projection_Status_Idle: "fires initialization of" 16 LazyProjection ||--|| Projection_Status_Idle: "by default" 17 Projection_Status_Idle ||--|| Projection_Status_Raw: "turns into" 18 Projection_Status_Raw ||--|| Projection_Status_Active: "turns into" 19 Projection_Status_Active ||--|| Actualizer: "fed by" 20 Actualizer ||--|| PLog: "reads from" 21 ``` 22 23 # Principles 24 - Lazy projection initialization triggered by: 25 - querying View which belongs to Lazy Projection from: 26 - QueryProcessor 27 - Actualizer 28 - Command processor can only read from the Views which are the part of Dynamic Projections; 29 30 # Implementation 31 - ProjectionKind is a part of projector specification: 32 - Dynamic (always active) 33 - ??? DynamicBuffered (always active, buffered intents) 34 - Lazy (initialized by request, buffered intents) 35 - CommandProcessor cannot read from Lazy projections, which throws error. 36 - UpdatedViews is a part of projector specification: [View1, View2, ...] 37 - Projection statuses kept by workspace: IDLE, RAW, ACTIVE 38 - Actualizer feeds event to projector: 39 - For Dynamic Projections - always; 40 - For Lazy Projections - only when projections for current workspace has status ACTIVE; 41 - When trigger activates idle projection initialization: 42 - projection status is set to RAW; 43 - a separate RawActualizer is created which reads from WLog and initializes raw projection (a pool of RawActualizer per AppPartition); 44 - when the raw projection is initialized, it's status set to ACTIVE: 45 - ??? synchronization between RawActualizer and Actualizer. 46 - In Actualizer and QueryProecssor: 47 - For [Lazy projections](./lazy-projections.md) check status: 48 - IDLE 49 - Send to initialization; 50 - Wait for some time; 51 - Return 503 if non initialzied; 52 - RAW: 53 - Wait for some time; 54 - Return 503 if non initialzied; 55 - ACTIVE: 56 - check consistency offset if specified; throw 503 if non consistent (some waiting is possible); 57 58 59 # See Also 60 - [Async Projections](https://dev.heeus.io/launchpad/#!17900)