moat-kv 0.70.24__py3-none-any.whl → 0.71.0__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.
- build/lib/moat/kv/_cfg.yaml +2 -6
- build/lib/moat/kv/backend/mqtt.py +0 -3
- ci/rtd-requirements.txt +4 -0
- ci/test-requirements.txt +7 -0
- ci/travis.sh +96 -0
- debian/.gitignore +7 -0
- debian/changelog +1435 -0
- debian/control +43 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_cfg.yaml +2 -6
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/mqtt.py +0 -3
- debian/moat-kv.postinst +3 -0
- debian/rules +20 -0
- debian/source/format +1 -0
- debian/watch +4 -0
- docs/Makefile +20 -0
- docs/make.bat +36 -0
- docs/source/TODO.rst +61 -0
- docs/source/_static/.gitkeep +0 -0
- docs/source/acls.rst +80 -0
- docs/source/auth.rst +84 -0
- docs/source/client_protocol.rst +456 -0
- docs/source/code.rst +341 -0
- docs/source/command_line.rst +1187 -0
- docs/source/common_protocol.rst +47 -0
- docs/source/debugging.rst +70 -0
- docs/source/extend.rst +37 -0
- docs/source/history.rst +36 -0
- docs/source/index.rst +75 -0
- docs/source/model.rst +54 -0
- docs/source/overview.rst +83 -0
- docs/source/related.rst +89 -0
- docs/source/server_protocol.rst +450 -0
- docs/source/startup.rst +31 -0
- docs/source/translator.rst +244 -0
- docs/source/tutorial.rst +711 -0
- docs/source/v3.rst +168 -0
- examples/code/transform.scale.yml +21 -0
- examples/code/transform.switch.yml +82 -0
- examples/code/transform.timeslot.yml +63 -0
- moat/kv/_cfg.yaml +2 -6
- moat/kv/backend/mqtt.py +0 -3
- {moat_kv-0.70.24.dist-info → moat_kv-0.71.0.dist-info}/METADATA +2 -5
- {moat_kv-0.70.24.dist-info → moat_kv-0.71.0.dist-info}/RECORD +68 -17
- scripts/current +15 -0
- scripts/env +8 -0
- scripts/init +39 -0
- scripts/recover +17 -0
- scripts/rotate +33 -0
- scripts/run +29 -0
- scripts/run-all +10 -0
- scripts/run-any +10 -0
- scripts/run-single +15 -0
- scripts/success +4 -0
- systemd/moat-kv-recover.service +21 -0
- systemd/moat-kv-rotate.service +20 -0
- systemd/moat-kv-rotate.timer +10 -0
- systemd/moat-kv-run-all.service +26 -0
- systemd/moat-kv-run-all@.service +25 -0
- systemd/moat-kv-run-any.service +26 -0
- systemd/moat-kv-run-any@.service +25 -0
- systemd/moat-kv-run-single.service +26 -0
- systemd/moat-kv-run-single@.service +25 -0
- systemd/moat-kv.service +27 -0
- systemd/postinst +7 -0
- systemd/sysusers +3 -0
- build/lib/moat/kv/backend/serf.py +0 -45
- build/lib/moat/kv/mock/serf.py +0 -250
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/serf.py +0 -45
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/serf.py +0 -250
- moat/kv/backend/serf.py +0 -45
- moat/kv/mock/serf.py +0 -250
- {moat_kv-0.70.24.dist-info → moat_kv-0.71.0.dist-info}/WHEEL +0 -0
- {moat_kv-0.70.24.dist-info → moat_kv-0.71.0.dist-info}/licenses/LICENSE.txt +0 -0
- {moat_kv-0.70.24.dist-info → moat_kv-0.71.0.dist-info}/top_level.txt +0 -0
debian/control
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Source: moat-kv
|
2
|
+
Maintainer: Matthias Urlichs <matthias@urlichs.de>
|
3
|
+
Section: python
|
4
|
+
Priority: optional
|
5
|
+
Build-Depends: dh-python, python3-all, debhelper (>= 13), debhelper-compat (= 13),
|
6
|
+
python3-setuptools,
|
7
|
+
python3-wheel,
|
8
|
+
Standards-Version: 3.9.6
|
9
|
+
Homepage: https://github.com/smurfix/moat
|
10
|
+
|
11
|
+
Package: moat-kv
|
12
|
+
Architecture: all
|
13
|
+
Depends: ${misc:Depends}, ${python3:Depends},
|
14
|
+
moat-mqtt (>= 0.38),
|
15
|
+
python3-anyio (>= 4),
|
16
|
+
python3-asyncclick (>= 1:8),
|
17
|
+
python3-asyncactor (>= 0.20),
|
18
|
+
python3-asyncscope (>= 0.5.5),
|
19
|
+
python3-attr (>= 19),
|
20
|
+
python3-systemd,
|
21
|
+
python3-range-set (>= 0.3),
|
22
|
+
python3-ruyaml (>= 0.89),
|
23
|
+
python3-simpleeval (>= 0.9.10),
|
24
|
+
moat-util,
|
25
|
+
moat-mqtt,
|
26
|
+
moat-main,
|
27
|
+
python3-moat-lib-diffiehellman,
|
28
|
+
systemd (>= 241),
|
29
|
+
Recommends:
|
30
|
+
python3-trio (>= 0.22),
|
31
|
+
Replaces: python3-distkv
|
32
|
+
Conflicts: python3-distkv
|
33
|
+
Description: A distributed no-master key-value store
|
34
|
+
MoaT-KV is a master-less distributed key-value storage system. It
|
35
|
+
circumvents the CAP theorem by assuming that keys are usually only changed
|
36
|
+
by one node. It is resistant to partitioning and intended to be always-on;
|
37
|
+
while it might delay – but will not lose – any updates.
|
38
|
+
.
|
39
|
+
MoaT-KV does not support data partitioning. Every node stores the whole
|
40
|
+
data set and can instantly deliver mostly-uptodate data.
|
41
|
+
.
|
42
|
+
MoaT-KV does not have a disk-based storage backend; periodic snapshots and/or
|
43
|
+
its event log are used to restore a system, if necessary.
|
@@ -26,7 +26,6 @@ runner: # for moat.kv.runner.RunnerRoot
|
|
26
26
|
state: !P :.moat.kv.state"
|
27
27
|
|
28
28
|
name: "run"
|
29
|
-
# Serf event name, suffixed by subpath
|
30
29
|
|
31
30
|
start_delay: 1
|
32
31
|
# time to wait between job starts. Not optional.
|
@@ -56,9 +55,6 @@ server:
|
|
56
55
|
# default
|
57
56
|
mqtt:
|
58
57
|
uri: "mqtt://localhost:1883"
|
59
|
-
serf:
|
60
|
-
host: "localhost"
|
61
|
-
port: 7373
|
62
58
|
|
63
59
|
# event message path/topic prefix
|
64
60
|
root: !P moat.kv
|
@@ -79,10 +75,10 @@ server:
|
|
79
75
|
ping:
|
80
76
|
cycle: 10
|
81
77
|
gap: 2
|
82
|
-
#
|
78
|
+
# asyncactor config timing for server sync
|
83
79
|
# ping also controls minimum server startup time
|
84
80
|
delete:
|
85
|
-
#
|
81
|
+
# asyncactor config timing for deletion
|
86
82
|
cycle: 100
|
87
83
|
gap: 10
|
88
84
|
version: 1
|
debian/moat-kv.postinst
ADDED
debian/rules
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/make -f
|
2
|
+
|
3
|
+
# This file was automatically generated by stdeb 0.8.5 at
|
4
|
+
# Sun, 21 Apr 2019 07:51:58 +0200
|
5
|
+
export PYBUILD_NAME=moat-kv
|
6
|
+
export LOG_CFG=$(shell pwd)/tests/logging.cfg
|
7
|
+
export MSGPACK_PUREPYTHON=1
|
8
|
+
%:
|
9
|
+
dh $@ --with python3 --buildsystem=pybuild
|
10
|
+
|
11
|
+
override_dh_install:
|
12
|
+
dh_install
|
13
|
+
$(MAKE) install PREFIX=debian/moat-kv
|
14
|
+
|
15
|
+
override_dh_python3:
|
16
|
+
dh_python3
|
17
|
+
rm -f debian/moat-kv/usr/lib/python3/dist-packages/test.log
|
18
|
+
|
19
|
+
override_dh_auto_test:
|
20
|
+
: skip
|
debian/source/format
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0 (quilt)
|
debian/watch
ADDED
docs/Makefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
2
|
+
#
|
3
|
+
|
4
|
+
# You can set these variables from the command line.
|
5
|
+
SPHINXOPTS =
|
6
|
+
SPHINXBUILD = sphinx-build
|
7
|
+
SPHINXPROJ = MoaT-KV
|
8
|
+
SOURCEDIR = source
|
9
|
+
BUILDDIR = build
|
10
|
+
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
12
|
+
help:
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
14
|
+
|
15
|
+
.PHONY: help Makefile
|
16
|
+
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
19
|
+
%: Makefile
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
docs/make.bat
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
@ECHO OFF
|
2
|
+
|
3
|
+
pushd %~dp0
|
4
|
+
|
5
|
+
REM Command file for Sphinx documentation
|
6
|
+
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
8
|
+
set SPHINXBUILD=sphinx-build
|
9
|
+
)
|
10
|
+
set SOURCEDIR=source
|
11
|
+
set BUILDDIR=build
|
12
|
+
set SPHINXPROJ=MoaT-KV
|
13
|
+
|
14
|
+
if "%1" == "" goto help
|
15
|
+
|
16
|
+
%SPHINXBUILD% >NUL 2>NUL
|
17
|
+
if errorlevel 9009 (
|
18
|
+
echo.
|
19
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
20
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
21
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
22
|
+
echo.may add the Sphinx directory to PATH.
|
23
|
+
echo.
|
24
|
+
echo.If you don't have Sphinx installed, grab it from
|
25
|
+
echo.http://sphinx-doc.org/
|
26
|
+
exit /b 1
|
27
|
+
)
|
28
|
+
|
29
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
30
|
+
goto end
|
31
|
+
|
32
|
+
:help
|
33
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
34
|
+
|
35
|
+
:end
|
36
|
+
popd
|
docs/source/TODO.rst
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
Open issues
|
2
|
+
===========
|
3
|
+
|
4
|
+
* Exchange a version code on startup
|
5
|
+
|
6
|
+
* CBOR
|
7
|
+
|
8
|
+
* Ping: ignore messages with decreasing tock (per node)
|
9
|
+
|
10
|
+
* chroot operation: add and test proper sub-roots, including auth and
|
11
|
+
whatnot
|
12
|
+
|
13
|
+
* We need path translation. Idea: store an extension element in the
|
14
|
+
destination path, which would pick the appropriate parts from the
|
15
|
+
source path when processed.
|
16
|
+
|
17
|
+
2-element tuples would probably work also, given that it's unlikely that
|
18
|
+
people use complex elements in their path, but why limit ourselves?
|
19
|
+
|
20
|
+
* ACLs for system data, i.e. those stored below ``None``.
|
21
|
+
|
22
|
+
* after starting with initial data, wait until the Actor is up and we're
|
23
|
+
synced to the other nodes
|
24
|
+
|
25
|
+
* Teach the server to also run an executor (or two or three or …)
|
26
|
+
|
27
|
+
* Rather than mangling split messages, use a MsgPack extension type.
|
28
|
+
|
29
|
+
* AnyRunner: Do proper load balancing; the leader should be able to tell
|
30
|
+
some other node to run a job if it's busy.
|
31
|
+
|
32
|
+
* Keep an error index on the server? Something more general?
|
33
|
+
|
34
|
+
* Restart code that's been changed (without waiting for restart/retry).
|
35
|
+
|
36
|
+
* Use cryptography.hazmat.primitives.asymmetric.x25519 instead of
|
37
|
+
Diffie-Hellman to send passwords to the server.
|
38
|
+
|
39
|
+
* Implement a shared secret to sign server-to-server messages.
|
40
|
+
|
41
|
+
* Runner: switch to monotonic time (except for target time!)
|
42
|
+
|
43
|
+
* Error consolidation: if a conflict doesn't get resolved on its own, do it
|
44
|
+
anyway when we are "it" next and >1 cycle has passed
|
45
|
+
|
46
|
+
* Add a command to cleanly flush the server log and stop the server.
|
47
|
+
|
48
|
+
* Test iterator on changed config entries
|
49
|
+
|
50
|
+
* errors: better display
|
51
|
+
|
52
|
+
* errors: manually acknowledge and delete them
|
53
|
+
|
54
|
+
* errors: add a web service to monitor them?
|
55
|
+
|
56
|
+
* Runner: store the number of active group members / actor config in the group
|
57
|
+
|
58
|
+
* Restore passing positional parameters as keywords (to code entries)
|
59
|
+
|
60
|
+
* Add a maintainer mode (user flag) that allows limited access when data is missing
|
61
|
+
|
File without changes
|
docs/source/acls.rst
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
==============
|
2
|
+
Access control
|
3
|
+
==============
|
4
|
+
|
5
|
+
MoaT-KV employs a two-step access control scheme.
|
6
|
+
|
7
|
+
First, you define an ACL hierarchy which controls which items may be
|
8
|
+
accessed using a particular named ACL. Then you associate that ACL
|
9
|
+
with users that shall be bound by it.
|
10
|
+
|
11
|
+
|
12
|
+
ACLs
|
13
|
+
====
|
14
|
+
|
15
|
+
An ACL entry controls these access modes:
|
16
|
+
|
17
|
+
* a: acl: retrieve the ACL flags for this node
|
18
|
+
* r: read: retrieve the data at this node
|
19
|
+
* w: write: change the data at this node
|
20
|
+
* c: create: add new data to this node
|
21
|
+
* d: delete: remove the data at this node
|
22
|
+
* x: access: read specific sub-nodes below this one
|
23
|
+
* e: enumerate: list sub-nodes of this one
|
24
|
+
* n: new: create new nodes below this one
|
25
|
+
|
26
|
+
In the MoaT-KV sources you'll also encounter these modes in calls to
|
27
|
+
``follow_acl`` (i.e. these flags can be checked for but you cannot set
|
28
|
+
them):
|
29
|
+
|
30
|
+
* W: check 'c' if the node is new or has no data, else 'w'
|
31
|
+
|
32
|
+
ACLs can use wildcards '+' (one level) and '#' (one or more levels).
|
33
|
+
Search is depth-first; more specific keys are checked first.
|
34
|
+
|
35
|
+
|
36
|
+
Association
|
37
|
+
===========
|
38
|
+
|
39
|
+
You change a user's ACL entry by adding an "acl=ACLNAME" field to the
|
40
|
+
user's aux data. The user is affected as soon as they log back in.
|
41
|
+
|
42
|
+
Updated ACL records are effective immediately.
|
43
|
+
|
44
|
+
|
45
|
+
Putting it all together
|
46
|
+
=======================
|
47
|
+
|
48
|
+
Given the following data structure, the user "aclix" will only be able to
|
49
|
+
write initial data to ``one`` and ``one two``. They can also read the data
|
50
|
+
back. However, any other access is not possible::
|
51
|
+
|
52
|
+
null:
|
53
|
+
auth:
|
54
|
+
_:
|
55
|
+
current: _test
|
56
|
+
_test:
|
57
|
+
user:
|
58
|
+
aclix:
|
59
|
+
_:
|
60
|
+
_aux:
|
61
|
+
acl: foo
|
62
|
+
std:
|
63
|
+
_:
|
64
|
+
_aux: {}
|
65
|
+
acl:
|
66
|
+
foo:
|
67
|
+
one:
|
68
|
+
_: rxnc
|
69
|
+
two:
|
70
|
+
_: rc
|
71
|
+
one:
|
72
|
+
_: 10
|
73
|
+
two:
|
74
|
+
_: 11
|
75
|
+
|
76
|
+
|
77
|
+
The above is the server content at the end of the testcase
|
78
|
+
``tests/test_feature_acls.py::test_81_basic``, when
|
79
|
+
dumped with the command ``moat kv : get -rd_``.
|
80
|
+
|
docs/source/auth.rst
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
=========================
|
2
|
+
MoaT-KV and authentication
|
3
|
+
=========================
|
4
|
+
|
5
|
+
MoaT-KV ships with a couple of rudimentary auth modules.
|
6
|
+
|
7
|
+
The server's initial message lists the accepted authentication methods
|
8
|
+
(``auth`` entry).
|
9
|
+
|
10
|
+
Depending on the server version, auth requests may be answered with a
|
11
|
+
stream even if the method doesn't actually require it. Login is successful
|
12
|
+
if the reply (or stream-end message) doesn't contain an error.
|
13
|
+
|
14
|
+
Included user auth methods
|
15
|
+
==========================
|
16
|
+
|
17
|
+
root
|
18
|
+
----
|
19
|
+
|
20
|
+
No access control. There is one possible user named "*"::
|
21
|
+
|
22
|
+
<<< {'seq': 0, 'version': (0, 58, 12), 'node': 'dev', 'auth': ('root',), …}
|
23
|
+
>>> {'typ': 'root', 'ident': '*', 'action': 'auth', 'seq': 1}
|
24
|
+
<<< {'state': 'start', 'seq': 2, 'wseq': 1, 'tock': 123}
|
25
|
+
<<< {'state': 'end', 'seq': 2, 'wseq': 2, 'tock': 124}
|
26
|
+
|
27
|
+
password
|
28
|
+
--------
|
29
|
+
|
30
|
+
This is the standard "username plus password" method. Passwords are hashed
|
31
|
+
and salted on the server; transmission of the cleartext password is
|
32
|
+
protected with a separate shared secret (Diffie-Hellman).
|
33
|
+
|
34
|
+
This method currently is a bit slow, unless you use test mode (in which
|
35
|
+
case it's a bit insecure).
|
36
|
+
|
37
|
+
The client initiates a Diffie-Hellman handshake if required, then wraps the
|
38
|
+
SHA256 of the password in a ``SecretBox`` (using a random nonce) and sends
|
39
|
+
that to the server. Logging in as ``root``::
|
40
|
+
|
41
|
+
<<< {'seq': 0, 'version': (0, 58, 12), 'node': 'dev', 'auth': ('password',), …}
|
42
|
+
>>> {'pubkey': b'[256 bytes]', 'length': 1024, 'action': 'diffie_hellman', 'seq': 1}
|
43
|
+
<<< {'pubkey': b'[256 bytes]', 'seq': 1, 'tock': 999}
|
44
|
+
>>> {'typ': 'password', 'ident': 'root', 'password': b'[data]', 'action': 'auth', 'seq': 2}
|
45
|
+
<<< {'state': 'start', 'seq': 2, 'wseq': 1, 'tock': 1001}
|
46
|
+
<<< {'state': 'end', 'seq': 2, 'wseq': 2, 'tock': 1002}
|
47
|
+
|
48
|
+
_test
|
49
|
+
-----
|
50
|
+
|
51
|
+
This is a test method that's suitable for experiments and testing.
|
52
|
+
|
53
|
+
Users do not have a password.
|
54
|
+
|
55
|
+
|
56
|
+
API
|
57
|
+
===
|
58
|
+
|
59
|
+
The authorization code is modular. MoaT-KV allows loading multiple auth
|
60
|
+
methods, one of which is active. A method may use more than one record type
|
61
|
+
(think "user" or "group"). Each of those records has a name.
|
62
|
+
|
63
|
+
The "user" type is only special because server and client use that to
|
64
|
+
process login requests.
|
65
|
+
|
66
|
+
Multiple distinct MoaT-KV domains or subdomains are possible, by adding an
|
67
|
+
additional meta-root record anywhere in the entry hierarchy.
|
68
|
+
|
69
|
+
|
70
|
+
.. module:: moat.kv.auth
|
71
|
+
|
72
|
+
.. autofunction:: loader
|
73
|
+
|
74
|
+
.. autoclass:: BaseServerAuth
|
75
|
+
:members:
|
76
|
+
|
77
|
+
.. autoclass:: BaseClientAuth
|
78
|
+
:members:
|
79
|
+
|
80
|
+
.. autoclass:: BaseServerAuthMaker
|
81
|
+
:members:
|
82
|
+
|
83
|
+
.. autoclass:: BaseClientAuthMaker
|
84
|
+
:members:
|