From 53a1c9af2ca5dc478a6450a1e0248bd3def0c483 Mon Sep 17 00:00:00 2001 From: Hiroki Uchikawa <31908137+HirokiUchikawa@users.noreply.github.com> Date: Tue, 27 Mar 2018 22:42:38 +0900 Subject: [PATCH] Updated Design: Persistable Context (markdown) --- Design:-Persistable-Context.md | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/Design:-Persistable-Context.md b/Design:-Persistable-Context.md index a0ff7f4..45163fd 100644 --- a/Design:-Persistable-Context.md +++ b/Design:-Persistable-Context.md @@ -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`. +## LocalFileSystem plugin +  The LocalFileSystem plugin is one of the bundle plugins for Persistable Context. +  This plugin stores context to Local File System. + +
+ +### Directory Structure +``` +$HOME/.node-red/contexts +├── global +│ └── global_context.json +├── +│ ├── flow_context.json +│ ├── .json +│ └── .json +└── + ├── flow_context.json + ├── .json + └── .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 \ directory as flow_context.json. +- `local context` is stored in \ directory as \.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" + } +} +``` +
+ ## Considerations #### Serializing/Deserializsing JavaScript Objects