-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersist.html
181 lines (161 loc) · 7.07 KB
/
persist.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<script type="text/javascript">
RED.nodes.registerType('persist-store',{
category: 'config',
defaults: {
filename: {value:"persistence.json",required:true},
interval: {value:60,required:true,validate:RED.validators.number()},
},
label: function() {
return this.filename;
}
});
</script>
<script type="text/x-red" data-template-name="persist-store">
<div class="form-row">
<label for="node-config-input-filename"><i class="icon-bookmark"></i> Filename</label>
<input type="text" id="node-config-input-filename">
</div>
<div class="form-row">
<label for="node-config-input-interval"><i class="icon-bookmark"></i> Interval [sec]</label>
<input type="text" id="node-config-input-interval">
</div>
</script>
<script type="text/x-red" data-help-name="persist-store">
<p>Stores the last messages received to file system to persist it during a node redeploy or system reboot.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>Filename <span class="property-type">string</span></dt>
<dd> the path and filename to use as the persistence store. Can be relative or absolute. Care for write accessability within the target directory.</dd>
<dt>Interval <span class="property-type">integer</span></dt>
<dd> the minimum buffer storing interval in seconds.</dd>
</dl>
<h3>Details</h3>
<p>Messages are stored in a memory buffer which is written to the filesystem. The buffer is stored every
<code>interval</code> seconds only if it has changed since the previous storing process, or on the next change if it had not
changed in the previous interval. Setting a large interval reduces the frequency of writes, but increases the
risk of data loss. The buffer is always stored when the node is stopped.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('persist in',{
category: 'storage',
color: '#33cccc',
defaults: {
name: {value:"", required: "true"},
storageNode: {value: "", type: "persist-store", required: "true"}
},
inputs:1,
outputs:0,
align: "right",
icon: "db.png",
label: function() {
return this.name||"persist";
}
});
</script>
<script type="text/x-red" data-template-name="persist in">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row" id="storageNode-row">
<label for="node-input-storageNode"><i class="fa fa-database"></i> Store</label>
<input type="text" id="node-input-storageNode">
</div>
</script>
<script type="text/x-red" data-help-name="persist in">
<p>Stores the last message received to the file system to persist it during a node redeploy
or system reboot.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>Name <span class="property-type">string</span> </dt>
<dd> the name of the persistence node. Messages saved by this node will be sent by the output node of the same name </dd>
<dt>Store <span class="property-type">Persistence store</span></dt>
<dd> the persistence store to save messages in.</dd>
</dl>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>msg <span class="property-type">msg</span></dt>
<dd> the entire message to be saved.</dd>
</dl>
<h3>Details</h3>
<p> When a flow is started, the last stored message is output. Messages that are received
by a named input node are replayed by the output node with the same name.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('persist out',{
category: 'storage',
color: '#33cccc',
defaults: {
name: {value:"", required: "true"},
storageNode: {value: "", type: "persist-store", required: "true"}
},
inputs:1,
outputs:1,
align: "left",
icon: "db.png",
label: function() {
return this.name||"persist";
},
button: {
onclick: function() {
$.ajax({
url: "persist/"+this.id,
type:"POST",
success: function(resp) {
RED.notify("Message restore","success");
},
error: function(jqXHR,textStatus,errorThrown) {
if (jqXHR.status == 404) {
RED.notify("Node not deployed","error");
} else if (jqXHR.status == 500) {
RED.notify("Message restore failed","error");
} else if (jqXHR.status == 0) {
RED.notify("No response","error");
} else {
RED.notify("Unexpected error " + textStatus,"error");
}
}
});
}
}
});
</script>
<script type="text/x-red" data-template-name="persist out">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row" id="storageNode-row">
<label for="node-input-storageNode"><i class="fa fa-database"></i> Store</label>
<input type="text" id="node-input-storageNode">
</div>
</script>
<script type="text/x-red" data-help-name="persist out">
<p>Replays the last message received that was stored to the file system to persist it during a node redeploy or system reboot.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>Name <span class="property-type">string</span> </dt>
<dd> the name of the persistence node. This node will send messages previously saved by the input node of the same name </dd>
<dt>Store <span class="property-type">Persistence store</span></dt>
<dd> the persistence store to read messages from.</dd>
</dl>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>msg
<span class="property-type">msg</span>
</dt>
<dd> any msg received will trigger a restore. </dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Output
<dl class="message-properties">
<dt>msg <span class="property-type">msg</span></dt>
<dd>the persisted messages.</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p> When a flow is started, the last stored message is output. A message received by a named input node is replayed by the output node with the same name.</p>
<p> Pressing the button on the node will trigger a replay of the most recently received message.</p>
</script>