1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Updated Design: Persistable Context (markdown)

Kazuki Nakanishi 2018-03-22 11:43:09 +09:00
parent d1ea11dd1e
commit 4197caf60c

@ -109,13 +109,13 @@ The value set in the config is passed to the plugin. These items are defined by
>>> DCJ: And if entire contextStorage section missing (as-in an upgrade where user hasn't edited settings.js) then use memory. >>> DCJ: And if entire contextStorage section missing (as-in an upgrade where user hasn't edited settings.js) then use memory.
>>>> KN: OK. I understand that we should distinguish the case between case 3 and the case that no contextStorage section exists. I added another scenario. >>>> KN: OK. I understand that we should distinguish the case between case 3 and the case that no contextStorage section exists. I added another scenario.
- There are three different scenarios when importing a flow that uses context storage. There are four different scenarios when importing a flow that uses context storage.
1. A user wants to run the flow as is by settings a context storage appropriately. 1. A user wants to run the flow as is by settings a context storage appropriately.
2. A user wants to always store context variable on the same storage (e.g. memory, file). 2. A user wants to always store context variable on the same storage (e.g. memory, file).
3. A user wants to receive an error if a context storage is used involuntarily. 3. A user wants to receive an error if a context storage is used involuntarily.
4. A user, who upgraded the Node-RED from the previous version without knowing persistable context feature, wants to always store context variable on the memory. 4. A user, who upgraded the Node-RED from the previous version without knowing persistable context feature, wants to always store context variable on the memory.
- To support all of the above cases, when the imported flow contains a persistable context: To support all of the above cases, when the imported flow contains a persistable context:
1. if the identifier is defined, use the context storage. 1. if the identifier is defined, use the context storage.
2. if the identifier is not defined but `default` identifier is defined, use the default context storage. 2. if the identifier is not defined but `default` identifier is defined, use the default context storage.
> DCJ: In this case - what happens if the default doesn't support a feature (like 'run(...') ? We should warn at least if not exact match. > DCJ: In this case - what happens if the default doesn't support a feature (like 'run(...') ? We should warn at least if not exact match.
@ -124,8 +124,18 @@ The value set in the config is passed to the plugin. These items are defined by
> DCJ: Yes not running but ideally still able to edit/correct the error if possible. > DCJ: Yes not running but ideally still able to edit/correct the error if possible.
>> KN: If a user does not specify `default` identifier, it means they declare that they want to receive an error instead of doing something. So I think that just throwing an exception with an appropriate error message would be fine. >> KN: If a user does not specify `default` identifier, it means they declare that they want to receive an error instead of doing something. So I think that just throwing an exception with an appropriate error message would be fine.
>>> NOL: To be clear - this only applies if they have `contextStorage` in their settings, but no `default` config within it? >>> NOL: To be clear - this only applies if they have `contextStorage` in their settings, but no `default` config within it?
>>>> KN: Yes, that's right. I've added a table below to clarify the conditions.
4. if the entire contextStorage section is missing in settings.js, use `memory` module (same as the current context). 4. if the entire contextStorage section is missing in settings.js, use `memory` module (same as the current context).
The table below shows the settting of `settings.js` for each case above.
| Case | `contextStorage` object in settings.js | appropriate identifier in `contextStorage` | `defualt` in `contextStorage` |
| ---- | --------- | --------- | -------- |
| 1 | Exists | Exists | Exists / Not exist|
| 2 | Exists | Not exist | Exists |
| 3 | Exists | Not exist | Not exist |
| 4 | Not exist | N/A | N/A |
## Executing plugin specific function ## Executing plugin specific function
Currently, `get` / `set` / `keys` is only methods to handle Context. Currently, `get` / `set` / `keys` is only methods to handle Context.
In Redis and others, an atomic API such as `INCR` can be used, but it can not be used in the current. In Redis and others, an atomic API such as `INCR` can be used, but it can not be used in the current.