github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/design/queryprocessor/README.md (about) 1 # Query Processor 2 A component which executes QueryFunctions and returns result to client 3 4 # User Stories 5 - Different types of results expected: 6 - many objects (Collection, ViewQueryFunc, WLogQueryFunc) 7 - single object (RecordQueryFunc) 8 - custom data (OpenApiSchemaFunc) 9 10 11 # Architecture 12 ```mermaid 13 erDiagram 14 AppPartition ||--|{ QueryProcessor: has 15 QueryProcessor ||--|{ QueryFunction: "executes" 16 QueryProcessor ||--|| State: has 17 QueryFunction ||--|| State: "reads from storages using" 18 QueryFunction ||--|| ArgumentObject: "reads" 19 QueryProcessor ||--|| ArgumentObject: "provides" 20 QueryProcessor ||--|| ExtensionEngine: uses 21 QueryProcessor ||--|| RowsProcessor: has 22 QueryFunction ||--|{ Object: generate 23 Object }|--|| RowsProcessor: "converted to rows by" 24 25 ``` 26 27 # Query Functions 28 ```mermaid 29 erDiagram 30 QueryFunction ||--|| BuiltinQueryFunction: "can be" 31 QueryFunction ||--|| RecordQueryFunc: "can be" 32 QueryFunction ||--|| ViewQueryFunc: "can be" 33 QueryFunction ||--|| CustomQueryFunc: "can be" 34 BuiltinQueryFunction ||--|| WLogQueryFunc: "can be" 35 BuiltinQueryFunction ||--|| OpenApiSchemaFunc: "can be" 36 BuiltinQueryFunction ||--|| CollectionFunc: "can be" 37 RecordQueryFunc ||--|| TableDecl: "built from" 38 ViewQueryFunc ||--|| ViewDecl: "built from" 39 CustomQueryFunctionDecl { 40 string Name 41 schema ArgumentObjectSchema 42 schema RresultObjectSchema 43 func Func 44 } 45 CustomQueryFunc ||--|| CustomQueryFunctionDecl: "built from" 46 OpenApiSchemaFunc ||--|| AppSchema: "uses" 47 CollectionFunc ||--|| AppSchema: "uses" 48 TableDecl }o--|| AppSchema: "declared by" 49 ViewDecl }o--|| AppSchema: "declared by" 50 CustomQueryFunctionDecl }o--|| AppSchema: "declared by" 51 ``` 52 53 # Principles 54 - QueryFunction 55 - Reads from Storages using State 56 - Not able to make any changes in Storages 57 - Three kinds of QueryFunction: 58 - Returning single object 59 - Generating many objects. 60 - Returning custom data. Content-type is defined by QueryFuntion declaration. 61 62 # Concepts 63 - QueryProcessor2 for using in API2 64 - Works with QueryFunctions of different types: 65 - Returning single object: result is a JSON object; 66 - Generating many objects. Function returns them to QueryProcessor via callback. QueryProcessor combines them in rows using RowsProcessor. Result is an JSON array of objects with optionally embedded objects (containers): [example](./request.md) 67 - Returning custom data. Results data with content-type defined by QueryFunction. 68 69 # See Also 70 - [Describe Heeus Functions in OpenAPI](https://dev.heeus.io/launchpad/#!19069) 71 - [A&D Query Processor](https://dev.heeus.io/launchpad/#!22705) 72 - [Consistency](../consistency/README.md)