From 4197caf60c49e28dc210569daff23b17b0260a73 Mon Sep 17 00:00:00 2001 From: Kazuki Nakanishi Date: Thu, 22 Mar 2018 11:43:09 +0900 Subject: [PATCH] Updated Design: Persistable Context (markdown) --- Design:-Persistable-Context.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Design:-Persistable-Context.md b/Design:-Persistable-Context.md index c3c4fdc..d158d93 100644 --- a/Design:-Persistable-Context.md +++ b/Design:-Persistable-Context.md @@ -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. >>>> 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. 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. 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. 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. @@ -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. >> 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? +>>>> 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). +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 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.