Skip to content

Commit 54006d8

Browse files
committed
Update processor signatures, terms and diagram
1 parent 7ec9327 commit 54006d8

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

rfcs/0014-task-workers.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ The pool should also be re-used when multiple projects are being built, either i
3232
* `Worker`: A Node.js [Worker thread](https://nodejs.org/api/worker_threads.html) instance
3333
* `Build Task`: A UI5 Tooling build task such as "minify" or "buildThemes" (standard tasks) or any [custom task](https://sap.github.io/ui5-tooling/stable/pages/extensibility/CustomTasks/)
3434
* `Task Processor`: A module associated with a UI5 Tooling Build Task (standard or custom) that can be executed in a `Worker`
35-
* `Dispatch Broker`: A ui5-project module coupled to the lifecycle of a Graph Build (similar to the `ProjectBuildContext`). It forwards requests from Build Tasks
35+
* `Build Context`: An already existing ui5-project module, coupled to the lifecycle of a Graph Build. It shall be extended to provide access to the `Work Dispatcher` by forwarding requests from `Build Tasks`
3636
* `Thread Runner`: A ui5-project module that will be loaded in a `Worker`. It handles communication with the main thread and executes a `Task Processor` on request
37-
* `Dispatcher`: A ui5-project singleton module which uses a library like [`workerpool`](https://github.com/josdejong/workerpool) to spawn and manage `Worker` instances in order to have them execute any `Task Processor` requested by the Build Task
37+
* `Work Dispatcher`: A ui5-project singleton module which uses a library like [`workerpool`](https://github.com/josdejong/workerpool) to spawn and manage `Worker` instances in order to have them execute any `Task Processor` requested by the Build Task
3838
- Handles the `Worker` lifecycle
3939

40-
![](./resources/0014-task-workers.png)
40+
![](./resources/0014-task-workers/Overview.png)
4141

4242
### Key Design Decisions
4343

@@ -61,21 +61,23 @@ The pool should also be re-used when multiple projects are being built, either i
6161
Similar to Tasks, Task Processors shall be invoked with a well defined signature:
6262

6363
* `resources`: An array of `@ui5/fs/Resource` provided by the Build Task
64-
* `options`: An object provided by the build task
65-
* `workspace`: Reader to read project files
66-
* `dependencies`: Reader or collection to read dependency files
64+
* `options`: An object provided by the Build Task
65+
* `fs`: An optional fs-interface provided by the Build Task
66+
* *[To be discussed] `workspace`: An optional workspace __reader__ provided by the Build Task*
67+
* *[To be discussed] `dependencies`: An optional dependencies reader provided by the Build Task*
68+
* *[To be discussed] `reader`: An optional generic reader provided by the Build Task*
6769

6870
```js
6971
/**
7072
* Task Processor example
7173
*
7274
* @param {Object} parameters Parameters
73-
* @param {DuplexCollection} parameters.workspace DuplexCollection to read and write files
74-
* @param {AbstractReader} parameters.dependencies Reader or Collection to read dependency files
75+
* @param {@ui5/fs/Resource[]} parameters.resources Array of resources provided by the build task
7576
* @param {Object} parameters.options Options provided by the calling task
76-
* @returns {Promise<object>} Promise resolving with an object containing the result of the process in an arbitrary format
77+
* @param {@ui5/fs/fsInterface} parameters.fs [fs interface]{@link module:@ui5/fs/fsInterface}-like class that internally handles communication with the main thread
78+
* @returns {Promise<object|@ui5/fs/Resource[]>} Promise resolving with either a flat object containing Resource instances as values, or an array of Resources
7779
*/
78-
module.exports = function({resources, workspace, dependencies, options}) {
80+
module.exports = function({resources, options, fs}) {
7981
// [...]
8082
};
8183
````
@@ -113,12 +115,13 @@ task:
113115
*/
114116
module.exports = function({workspace, options, processors}) {
115117
const res = await processors.execute("computePi", {
118+
resources: [workspace.byPath("/already-computed.txt")]
116119
options: {
117-
digits: 1000000
120+
digits: 1_000_000_000_000_000_000_000
118121
},
119-
workspace, // optional overwrite of the workspace parameter
120-
dependencies, // optional overwrite of the dependencies parameter
122+
fs: fsInterface(workspace) // To allow reading additional files if necessary
121123
});
124+
await workspace.write(res);
122125
// [...]
123126
};
124127
````
25 KB
Binary file not shown.

rfcs/resources/0014-task-workers.png

-40.4 KB
Binary file not shown.
44.8 KB
Loading

0 commit comments

Comments
 (0)