moat-kv 0.71.0__py3-none-any.whl → 0.71.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. moat/kv/__init__.py +6 -7
  2. moat/kv/_cfg.yaml +3 -2
  3. moat/kv/actor/__init__.py +2 -1
  4. moat/kv/actor/deletor.py +4 -1
  5. moat/kv/auth/__init__.py +12 -13
  6. moat/kv/auth/_test.py +4 -1
  7. moat/kv/auth/password.py +11 -7
  8. moat/kv/backend/mqtt.py +4 -5
  9. moat/kv/client.py +20 -39
  10. moat/kv/code.py +3 -3
  11. moat/kv/command/data.py +4 -3
  12. moat/kv/command/dump/__init__.py +36 -34
  13. moat/kv/command/internal.py +2 -3
  14. moat/kv/command/job.py +1 -2
  15. moat/kv/command/type.py +3 -6
  16. moat/kv/data.py +9 -8
  17. moat/kv/errors.py +16 -8
  18. moat/kv/mock/__init__.py +2 -12
  19. moat/kv/model.py +29 -33
  20. moat/kv/obj/__init__.py +3 -3
  21. moat/kv/obj/command.py +3 -3
  22. moat/kv/runner.py +4 -5
  23. moat/kv/server.py +106 -126
  24. moat/kv/types.py +10 -12
  25. {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/METADATA +6 -2
  26. moat_kv-0.71.7.dist-info/RECORD +47 -0
  27. {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/WHEEL +1 -1
  28. moat_kv-0.71.7.dist-info/licenses/LICENSE +3 -0
  29. moat_kv-0.71.7.dist-info/licenses/LICENSE.APACHE2 +202 -0
  30. moat_kv-0.71.7.dist-info/licenses/LICENSE.MIT +20 -0
  31. moat_kv-0.71.7.dist-info/top_level.txt +1 -0
  32. build/lib/docs/source/conf.py +0 -201
  33. build/lib/examples/pathify.py +0 -45
  34. build/lib/moat/kv/__init__.py +0 -19
  35. build/lib/moat/kv/_cfg.yaml +0 -93
  36. build/lib/moat/kv/_main.py +0 -91
  37. build/lib/moat/kv/actor/__init__.py +0 -98
  38. build/lib/moat/kv/actor/deletor.py +0 -139
  39. build/lib/moat/kv/auth/__init__.py +0 -444
  40. build/lib/moat/kv/auth/_test.py +0 -166
  41. build/lib/moat/kv/auth/password.py +0 -234
  42. build/lib/moat/kv/auth/root.py +0 -58
  43. build/lib/moat/kv/backend/__init__.py +0 -67
  44. build/lib/moat/kv/backend/mqtt.py +0 -71
  45. build/lib/moat/kv/client.py +0 -1025
  46. build/lib/moat/kv/code.py +0 -236
  47. build/lib/moat/kv/codec.py +0 -11
  48. build/lib/moat/kv/command/__init__.py +0 -1
  49. build/lib/moat/kv/command/acl.py +0 -180
  50. build/lib/moat/kv/command/auth.py +0 -261
  51. build/lib/moat/kv/command/code.py +0 -293
  52. build/lib/moat/kv/command/codec.py +0 -186
  53. build/lib/moat/kv/command/data.py +0 -265
  54. build/lib/moat/kv/command/dump/__init__.py +0 -143
  55. build/lib/moat/kv/command/error.py +0 -149
  56. build/lib/moat/kv/command/internal.py +0 -248
  57. build/lib/moat/kv/command/job.py +0 -433
  58. build/lib/moat/kv/command/log.py +0 -53
  59. build/lib/moat/kv/command/server.py +0 -114
  60. build/lib/moat/kv/command/type.py +0 -201
  61. build/lib/moat/kv/config.py +0 -46
  62. build/lib/moat/kv/data.py +0 -216
  63. build/lib/moat/kv/errors.py +0 -561
  64. build/lib/moat/kv/exceptions.py +0 -126
  65. build/lib/moat/kv/mock/__init__.py +0 -101
  66. build/lib/moat/kv/mock/mqtt.py +0 -159
  67. build/lib/moat/kv/mock/tracer.py +0 -63
  68. build/lib/moat/kv/model.py +0 -1069
  69. build/lib/moat/kv/obj/__init__.py +0 -646
  70. build/lib/moat/kv/obj/command.py +0 -241
  71. build/lib/moat/kv/runner.py +0 -1347
  72. build/lib/moat/kv/server.py +0 -2809
  73. build/lib/moat/kv/types.py +0 -513
  74. ci/rtd-requirements.txt +0 -4
  75. ci/test-requirements.txt +0 -7
  76. ci/travis.sh +0 -96
  77. debian/.gitignore +0 -7
  78. debian/changelog +0 -1435
  79. debian/control +0 -43
  80. debian/moat-kv/usr/lib/python3/dist-packages/docs/source/conf.py +0 -201
  81. debian/moat-kv/usr/lib/python3/dist-packages/examples/pathify.py +0 -45
  82. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/__init__.py +0 -19
  83. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_cfg.yaml +0 -93
  84. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_main.py +0 -91
  85. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/__init__.py +0 -98
  86. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/deletor.py +0 -139
  87. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/__init__.py +0 -444
  88. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/_test.py +0 -166
  89. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/password.py +0 -234
  90. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/root.py +0 -58
  91. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/__init__.py +0 -67
  92. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/mqtt.py +0 -71
  93. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/client.py +0 -1025
  94. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/code.py +0 -236
  95. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/codec.py +0 -11
  96. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/__init__.py +0 -1
  97. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/acl.py +0 -180
  98. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/auth.py +0 -261
  99. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/code.py +0 -293
  100. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/codec.py +0 -186
  101. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/data.py +0 -265
  102. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/dump/__init__.py +0 -143
  103. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/error.py +0 -149
  104. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/internal.py +0 -248
  105. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/job.py +0 -433
  106. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/log.py +0 -53
  107. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/server.py +0 -114
  108. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/type.py +0 -201
  109. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/config.py +0 -46
  110. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/data.py +0 -216
  111. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/errors.py +0 -561
  112. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/exceptions.py +0 -126
  113. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/__init__.py +0 -101
  114. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/mqtt.py +0 -159
  115. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/tracer.py +0 -63
  116. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/model.py +0 -1069
  117. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/__init__.py +0 -646
  118. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/command.py +0 -241
  119. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/runner.py +0 -1347
  120. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/server.py +0 -2809
  121. debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/types.py +0 -513
  122. debian/moat-kv.postinst +0 -3
  123. debian/rules +0 -20
  124. debian/source/format +0 -1
  125. debian/watch +0 -4
  126. docs/Makefile +0 -20
  127. docs/make.bat +0 -36
  128. docs/source/TODO.rst +0 -61
  129. docs/source/_static/.gitkeep +0 -0
  130. docs/source/acls.rst +0 -80
  131. docs/source/auth.rst +0 -84
  132. docs/source/client_protocol.rst +0 -456
  133. docs/source/code.rst +0 -341
  134. docs/source/command_line.rst +0 -1187
  135. docs/source/common_protocol.rst +0 -47
  136. docs/source/conf.py +0 -201
  137. docs/source/debugging.rst +0 -70
  138. docs/source/extend.rst +0 -37
  139. docs/source/history.rst +0 -36
  140. docs/source/index.rst +0 -75
  141. docs/source/model.rst +0 -54
  142. docs/source/overview.rst +0 -83
  143. docs/source/related.rst +0 -89
  144. docs/source/server_protocol.rst +0 -450
  145. docs/source/startup.rst +0 -31
  146. docs/source/translator.rst +0 -244
  147. docs/source/tutorial.rst +0 -711
  148. docs/source/v3.rst +0 -168
  149. examples/code/transform.scale.yml +0 -21
  150. examples/code/transform.switch.yml +0 -82
  151. examples/code/transform.timeslot.yml +0 -63
  152. examples/pathify.py +0 -45
  153. moat/kv/codec.py +0 -11
  154. moat_kv-0.71.0.dist-info/RECORD +0 -188
  155. moat_kv-0.71.0.dist-info/top_level.txt +0 -9
  156. scripts/current +0 -15
  157. scripts/env +0 -8
  158. scripts/init +0 -39
  159. scripts/recover +0 -17
  160. scripts/rotate +0 -33
  161. scripts/run +0 -29
  162. scripts/run-all +0 -10
  163. scripts/run-any +0 -10
  164. scripts/run-single +0 -15
  165. scripts/success +0 -4
  166. systemd/moat-kv-recover.service +0 -21
  167. systemd/moat-kv-rotate.service +0 -20
  168. systemd/moat-kv-rotate.timer +0 -10
  169. systemd/moat-kv-run-all.service +0 -26
  170. systemd/moat-kv-run-all@.service +0 -25
  171. systemd/moat-kv-run-any.service +0 -26
  172. systemd/moat-kv-run-any@.service +0 -25
  173. systemd/moat-kv-run-single.service +0 -26
  174. systemd/moat-kv-run-single@.service +0 -25
  175. systemd/moat-kv.service +0 -27
  176. systemd/postinst +0 -7
  177. systemd/sysusers +0 -3
  178. {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,244 +0,0 @@
1
- =================================
2
- Verifying and Translating Entries
3
- =================================
4
-
5
- ++++++++++++
6
- Verification
7
- ++++++++++++
8
-
9
- Your application may require consistency guarantees. Instead of committing
10
- fraud when a transaction in your bookkeeping system doesn't add up to zero,
11
- you might want to add a verification step to make sure that that doesn't
12
- happen in the first place. More prosaically, the statement "The door is
13
- locked" is either True or False. (However, you always should be prepared
14
- for an answer of "No idea", aka ``None``. That's not avoidable.)
15
-
16
-
17
- Types
18
- =====
19
-
20
- Type entries may contain a ``schema`` attribute with a JSON Schema that
21
- verifies the data. They also may contain a ``code`` attribute which forms
22
- the body of a validation procedure. The variable ``value`` contains the
23
- value in question.
24
-
25
- Type entries are hierarchic: An ("int","percent") type is first validated
26
- against (None,"type","int"), then against (None,"type","int","percent").
27
-
28
- Type checkers cannot modify data.
29
-
30
- Type check entries *must* be accompanied by "good" and "bad" values, which
31
- must be non-empty arrays of values which pass or fail this type check. For
32
- subordinate types, both kinds must pass the supertype check: if you
33
- add a type "float percentage", the ``bad`` list may contain values like ``-1.2`` or
34
- ``123.45``, but not ``"hello"``.
35
-
36
- Beware that restricting an existing type is dangerous. The MoaT-KV server
37
- does not verify that all existing entries verify correctly.
38
- In pedantic mode, your network may no longer load its data or converge.
39
-
40
-
41
- Matches
42
- =======
43
-
44
- The (None,"match") hierarchy mirrors the actual object tree, except that
45
- wildcards are allowed:
46
-
47
- * "#"
48
-
49
- matches any number of levels
50
-
51
- * "+"
52
-
53
- matches exactly one level
54
-
55
- This matches MQTT's behavior.
56
-
57
- Unlike MQTT, there may be more than one "#" wildcard.
58
-
59
- Be aware that adding or modifying matches to existing entries is dangerous.
60
- The MoaT-KV server does not verify that all existing entries verify correctly.
61
- In pedantic mode, your network may no longer load its data or converge.
62
-
63
-
64
- Putting it all together
65
- =======================
66
-
67
- Given the following structure, values stored at ("foo", anything, "bar")
68
- must be integers::
69
-
70
- match:
71
- foo:
72
- +:
73
- bar:
74
- _:
75
- type:
76
- - int
77
- - percent
78
- type:
79
- int:
80
- _:
81
- bad: [none, "foo"]
82
- code: 'if not isinstance(value,int): raise ValueError(''not an int'')'
83
- good: [0,2]
84
- percent:
85
- _:
86
- bad: [-1,555]
87
- code: 'if not 0<=value<=100: raise ValueError(''not a percentage'')'
88
- good: [0,100,50]
89
- ---
90
- _: 123
91
- foo:
92
- dud:
93
- bar:
94
- _: 55
95
-
96
- The above is the server content at the end of the testcase
97
- ``tests/test_feature_typecheck.py::test_72_cmd``, when
98
- dumped with the commands ``moat kv internal dump`` and
99
- ``moat kv «path» get -rd_``.
100
-
101
- On the command line, you can do the same thing thus::
102
-
103
- $ echo "if not isinstance(value,int): raise ValueError('not an int')" | \
104
- moat kv type set -b None -b '"foo"' -g 0 -g 2 -s - int
105
- $ echo "if not 0<=value<=100: raise ValueError('not a percentage')" | \
106
- moat kv type set -b -1 -b 555 -g 0 -g 100 -g 50 -s - int percent
107
- $ moat kv type match -t int -t percent foo + bar
108
-
109
- +++++++++++
110
- Translation
111
- +++++++++++
112
-
113
- Sometimes, clients need special treatment. For instance, an IoT-MQTT message
114
- that reports turning on a light might send "ON" to topic
115
- ``/home/state/bath/light``, while what you'd really like to do is to change
116
- the Boolean ``state`` attribute of ``home.bath.light``. Or maybe the value
117
- is a percentage and you'd like to ensure that the stored value is 0.5
118
- instead of "50%", and that no rogue client can set it to -20 or "gotcha".
119
-
120
- To ensure this, MoaT-KV uses two typing mechanisms. One has been described,
121
- above, and ensures that the values are correct:
122
-
123
- * "type" entries describe the type of entry ("this is an integer between 0
124
- and 42").
125
-
126
- * "match" entries describe the path position to which that type applies
127
-
128
- Another, similar mechanism may then be used to convert clients' values to
129
- MoaT-KV entries and back:
130
-
131
- * "codec" entries describe distinct converters ("50%" => 0.5; "ON" => 'set
132
- the entry's "state" property to ``True``')
133
-
134
- * "map" entries are activated per client (via command, or controlled by its
135
- login) and describe the path position to which a codec applies
136
-
137
-
138
- Codecs
139
- ======
140
-
141
- Codec entries contain ``decode`` and ``encode`` attributes which form the
142
- bodies of procedures that rewrite external data to MoaT-KV values and vice
143
- versa, respectively, using the ``value`` parameter as input. The ``decode``
144
- procedure gets an additional ``prev`` variable which contains the old
145
- value. That value **must not** be modified; create a copy or (preferably)
146
- use :func:`moat.util.combine_dict` to assemble the result.
147
-
148
- Codecs may be named hierarchically for convenience; if you want to
149
- call the "parent" codec, put the common code in a module and import that.
150
-
151
- Codecs also require "in" and "out" attributes, each of which must contain a list
152
- of 2-tuples with that conversion's source value and its result. "in"
153
- corresponds to decoding, "out" to encoding – much like Python's binary
154
- codecs.
155
-
156
-
157
- Converters
158
- ==========
159
-
160
- While the ``(None,"map")`` subtree contains a single mapping, ``(None,"conv")``
161
- uses an additional single level of codec group names. A mapping must be
162
- applied to a user (by adding a "conv=GROUPNAME" to the user's aux data
163
- field) before it is used. This change is instantaneous, i.e. an existing
164
- user does not need to reconnect.
165
-
166
- Below that, converter naming works like that for mappings. Of course, the
167
- pointing attribute is named ``codec`` instead of ``type``.
168
-
169
-
170
- Putting it all together
171
- =======================
172
-
173
- Given the following data structure, the user "conv" will only be able to
174
- write stringified integers under keys below the "inty" key, which will be
175
- stored as integers::
176
-
177
-
178
- auth:
179
- _:
180
- current: _test
181
- _test:
182
- user:
183
- con:
184
- _:
185
- _aux:
186
- conv: foo
187
- std:
188
- _:
189
- _aux: {}
190
- codec:
191
- int:
192
- _:
193
- decode: assert isinstance(value,str); return int(value)
194
- encode: return str(value)
195
- in:
196
- - [ '1', 1 ]
197
- - [ '2', 2 ]
198
- - [ '3', 3 ]
199
- out:
200
- - [ 1, '1' ]
201
- - [ 2, '2' ]
202
- - [ -3, '-3' ]
203
- conv:
204
- foo:
205
- inty:
206
- '#':
207
- _:
208
- codec:
209
- - int
210
- ---
211
- inty:
212
- _: hello
213
- ten:
214
- _: 10
215
- yep:
216
- yepyepyep:
217
- _: 13
218
- yep:
219
- _: 99
220
-
221
-
222
- The above is the server content at the end of the testcase
223
- ``tests/test_feature_convert.py::test_71_basic``, when
224
- dumped with the commands ``moat kv internal dump`` and
225
- ``moat kv «path» get -rd_``.
226
-
227
- Paths
228
- =====
229
-
230
- Currently, MoaT-KV does not offer automatic path translation. If you need
231
- that, the best way is to code two active object hierarchies, and
232
- let their ``set_value`` methods shuffle data to the "other" side.
233
-
234
- There are some caveats:
235
-
236
- * All such data are stored twice.
237
-
238
- * Don't change a value that didn't in fact change; if you do, you'll
239
- generate an endless loop.
240
-
241
- * You need to verify that the two trees match when you start up, and decide
242
- which is more correct. (The ``tock`` stamp will help you here.) Don't
243
- accidentally overwrite changes that arrive while you do that.
244
-