mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Updated Design: Persistable Context (markdown)
parent
24e72ec4d3
commit
53a1c9af2c
@ -152,6 +152,77 @@ It executes plugin specific function passed in the argument `command`.
|
|||||||
|
|
||||||
**Returns** a value that plugin specific function returns. If the plugin return nothing like a `set`, `run` will return `undefined`.
|
**Returns** a value that plugin specific function returns. If the plugin return nothing like a `set`, `run` will return `undefined`.
|
||||||
|
|
||||||
|
## LocalFileSystem plugin
|
||||||
|
The LocalFileSystem plugin is one of the bundle plugins for Persistable Context.
|
||||||
|
This plugin stores context to Local File System.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
### Directory Structure
|
||||||
|
```
|
||||||
|
$HOME/.node-red/contexts
|
||||||
|
├── global
|
||||||
|
│ └── global_context.json
|
||||||
|
├── <id of Flow 1>
|
||||||
|
│ ├── flow_context.json
|
||||||
|
│ ├── <id of Node a>.json
|
||||||
|
│ └── <id of Node b>.json
|
||||||
|
└── <id of Flow 2>
|
||||||
|
├── flow_context.json
|
||||||
|
├── <id of Node x>.json
|
||||||
|
└── <id of Node y>.json
|
||||||
|
```
|
||||||
|
- The plugin creates `settings.userDir`/contexts directory if `config.dir` is not passed.
|
||||||
|
- `global context` is stored in global directory as global_context.json.
|
||||||
|
- `flow context` is stored in \<id of the flow> directory as flow_context.json.
|
||||||
|
- `local context` is stored in \<id of the flow it is in> directory as \<id of the node>.json.
|
||||||
|
|
||||||
|
#### example
|
||||||
|
|
||||||
|
```
|
||||||
|
+--------+
|
||||||
|
+ Flow A +
|
||||||
|
+--------+----------------------------+
|
||||||
|
+ +
|
||||||
|
+ +----------+ +----------+ +
|
||||||
|
+ +timestamp +--------+ function + +
|
||||||
|
+ +----------+ +----------+ +
|
||||||
|
+ +
|
||||||
|
+-------------------------------------+
|
||||||
|
```
|
||||||
|
- The id of the Flow A is `8588e4b8.784b38`
|
||||||
|
- The id of the function node is `80d8039e.2b82`
|
||||||
|
- The function node stores data to local, flow and global context in local file system.
|
||||||
|
- The following directories and files are created after the Flow A runs.
|
||||||
|
```
|
||||||
|
.node-red/contexts
|
||||||
|
├── global
|
||||||
|
│ └── global_context.json
|
||||||
|
└── 8588e4b8.784b38
|
||||||
|
├── flow_context.json
|
||||||
|
└── 80d8039e.2b82.json
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### File Format
|
||||||
|
- The plugin stores data as formatted JSON.
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"key": "value",
|
||||||
|
"num": 123456,
|
||||||
|
"array": [
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3"
|
||||||
|
],
|
||||||
|
"object": {
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
## Considerations
|
## Considerations
|
||||||
|
|
||||||
#### Serializing/Deserializsing JavaScript Objects
|
#### Serializing/Deserializsing JavaScript Objects
|
||||||
|
Loading…
Reference in New Issue
Block a user