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,101 +0,0 @@
1
- # from asyncclick.testing import CliRunner
2
- from __future__ import annotations
3
- import io
4
- import logging
5
- import shlex
6
- import socket
7
- import sys
8
- from pathlib import Path
9
-
10
- import attr
11
- from asyncscope import main_scope, scope
12
- from moat.src.test import run # pylint:disable=import-error,no-name-in-module
13
- from moat.util import ( # pylint:disable=no-name-in-module
14
- CFG,
15
- OptCtx,
16
- attrdict,
17
- combine_dict,
18
- ensure_cfg,
19
- list_ext,
20
- load_ext,
21
- wrap_main,
22
- yload,
23
- )
24
-
25
- from moat.kv.client import _scoped_client, client_scope
26
-
27
- logger = logging.getLogger(__name__)
28
- try:
29
- from contextlib import asynccontextmanager
30
- except ImportError:
31
- from async_generator import asynccontextmanager
32
-
33
- ensure_cfg("moat.kv")
34
-
35
-
36
- @attr.s
37
- class S:
38
- tg = attr.ib()
39
- client_ctx = attr.ib()
40
- s = attr.ib(factory=list) # servers
41
- c = attr.ib(factory=list) # clients
42
- _seq = 1
43
-
44
- async def ready(self, i=None):
45
- if i is not None:
46
- await self.s[i].is_ready
47
- return self.s[i]
48
- for s in self.s:
49
- if s is not None:
50
- await s.is_ready
51
- return self.s
52
-
53
- def __iter__(self):
54
- return iter(self.s)
55
-
56
- @asynccontextmanager
57
- async def client(self, i: int = 0, **kv):
58
- """Get a (new) client for the i'th server."""
59
- await self.s[i].is_serving
60
- self._seq += 1
61
- for host, port, *_ in self.s[i].ports:
62
- if host != "::" and host[0] == ":":
63
- continue
64
- try:
65
- cfg = combine_dict(
66
- dict(conn=dict(host=host, port=port, ssl=self.client_ctx, **kv)),
67
- CFG["kv"],
68
- )
69
-
70
- async def scc(s, **cfg):
71
- scope.requires(s._scope)
72
- return await _scoped_client(scope.name, **cfg)
73
-
74
- async with scope.using_scope():
75
- c = await scope.service(
76
- f"moat.kv.client.{i}.{self._seq}",
77
- scc,
78
- self.s[i],
79
- **cfg,
80
- )
81
- yield c
82
- return
83
- except socket.gaierror:
84
- pass
85
- raise RuntimeError("Duh? no connection")
86
-
87
- async def run(self, *args, do_stdout=True):
88
- h = p = None
89
- for s in self.s:
90
- for h, p, *_ in s.ports:
91
- if h[0] != ":":
92
- break
93
- else:
94
- continue
95
- break
96
- if len(args) == 1:
97
- args = args[0]
98
- if isinstance(args, str):
99
- args = args.split(" ")
100
- async with scope.using_scope():
101
- return await run("-VV", "kv", "-h", h, "-p", p, *args, do_stdout=do_stdout)
@@ -1,159 +0,0 @@
1
- from __future__ import annotations
2
- import copy
3
- import logging
4
- import os
5
- import time
6
- from contextlib import AsyncExitStack, asynccontextmanager
7
- from functools import partial
8
-
9
- import anyio
10
- from unittest import mock
11
- import trio
12
- from asyncscope import main_scope, scope
13
- from moat.mqtt.broker import create_broker
14
- from moat.util import NotGiven, attrdict, combine_dict
15
-
16
- from moat.kv.mock import S
17
- from moat.kv.server import Server
18
-
19
- from . import CFG
20
-
21
- logger = logging.getLogger(__name__)
22
-
23
- otm = time.time
24
-
25
- PORT = 40000 + (os.getpid() + 10) % 10000
26
-
27
- broker_cfg = {
28
- "listeners": {"default": {"type": "tcp", "bind": f"127.0.0.1:{PORT}"}},
29
- "timeout-disconnect-delay": 2,
30
- "auth": {"allow-anonymous": True, "password-file": None},
31
- }
32
-
33
- URI = f"mqtt://127.0.0.1:{PORT}/"
34
-
35
-
36
- @asynccontextmanager
37
- async def stdtest(n=1, run=True, ssl=False, tocks=20, **kw):
38
- C_OUT = CFG.get("_stdout", NotGiven)
39
- if C_OUT is not NotGiven:
40
- del CFG["_stdout"]
41
- TESTCFG = copy.deepcopy(CFG["kv"])
42
- TESTCFG.server.port = None
43
- TESTCFG.root = "test"
44
- if C_OUT is not NotGiven:
45
- CFG["_stdout"] = C_OUT
46
- TESTCFG["_stdout"] = C_OUT
47
-
48
- if ssl:
49
- import ssl
50
-
51
- import trustme
52
-
53
- ca = trustme.CA()
54
- cert = ca.issue_server_cert("127.0.0.1")
55
- server_ctx = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
56
- client_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)
57
- ca.configure_trust(client_ctx)
58
- cert.configure_cert(server_ctx)
59
- else:
60
- server_ctx = client_ctx = False
61
-
62
- clock = trio.lowlevel.current_clock()
63
- try:
64
- clock.autojump_threshold = 0.02 # networking
65
- except Exception:
66
- pass # test doesn't have autojump_clock fixture
67
-
68
- async def mock_get_host_port(st, host):
69
- i = int(host[host.rindex("_") + 1 :])
70
- s = st.s[i]
71
- await s.is_serving
72
- for host, port, *_ in s.ports:
73
- if host == "::" or host[0] != ":":
74
- return host, port
75
-
76
- def tm():
77
- try:
78
- return trio.current_time()
79
- except RuntimeError:
80
- return otm()
81
-
82
- async def mock_set_tock(self, old):
83
- assert self._tock < tocks, "Test didn't terminate. Limit:" + str(tocks)
84
- await old()
85
-
86
- done = False
87
- async with main_scope("moat.kv.test.mqtt") as scp:
88
- tg = scp._tg
89
- st = S(tg, client_ctx)
90
- async with AsyncExitStack() as ex:
91
- st.ex = ex # pylint: disable=attribute-defined-outside-init
92
- ex.enter_context(mock.patch("time.time", new=tm))
93
- ex.enter_context(mock.patch("time.monotonic", new=tm))
94
- logging._startTime = tm()
95
-
96
- async def run_broker(cfg):
97
- async with create_broker(config=cfg) as srv:
98
- # NB: some services use "async with await …"
99
- scope.register(srv)
100
- await scope.no_more_dependents()
101
-
102
- async def with_broker(s, *a, **k):
103
- await scope.service("moat.mqtt.broker", run_broker, broker_cfg)
104
- s._scope = scope.get()
105
- return await s._scoped_serve(*a, **k)
106
-
107
- args_def = kw.get("args", attrdict())
108
- for i in range(n):
109
- name = "test_" + str(i)
110
- args = kw.get(name, args_def)
111
- args = combine_dict(
112
- args,
113
- args_def,
114
- {
115
- "cfg": {
116
- "conn": {"ssl": client_ctx},
117
- "server": {
118
- "bind_default": {
119
- "host": "127.0.0.1",
120
- "port": i + PORT + 1,
121
- "ssl": server_ctx,
122
- },
123
- "backend": "mqtt",
124
- "mqtt": {"uri": URI},
125
- },
126
- },
127
- },
128
- {"cfg": TESTCFG},
129
- )
130
- args_def.pop("init", None)
131
- s = Server(name, **args)
132
- ex.enter_context(
133
- mock.patch.object(s, "_set_tock", new=partial(mock_set_tock, s, s._set_tock)),
134
- )
135
- ex.enter_context(
136
- mock.patch.object(s, "_get_host_port", new=partial(mock_get_host_port, st)),
137
- )
138
- st.s.append(s)
139
-
140
- evts = []
141
- for i in range(n):
142
- if kw.get(f"run_{i}", run):
143
- evt = anyio.Event()
144
- await scp.spawn_service(with_broker, st.s[i], ready_evt=evt)
145
- evts.append(evt)
146
- else:
147
- setattr(st, f"run_{i}", partial(scp.spawn_service, with_broker, st.s[i]))
148
-
149
- for e in evts:
150
- await e.wait()
151
- try:
152
- done = True
153
- yield st
154
- finally:
155
- with anyio.fail_after(2, shield=True):
156
- logger.info("Runtime: %s", clock.current_time())
157
- tg.cancel_scope.cancel()
158
- if not done:
159
- yield None
@@ -1,63 +0,0 @@
1
- from __future__ import annotations
2
- import traceback
3
-
4
- import trio
5
- from outcome import Error
6
-
7
- import moat
8
-
9
- moat.kill = False
10
-
11
- import logging
12
-
13
- logger = logging.getLogger("TRACE")
14
- e = logger.error
15
-
16
-
17
- class Tracer(trio.abc.Instrument):
18
- def __init__(self):
19
- super().__init__()
20
- self.etasks = set()
21
-
22
- def _print_with_task(self, msg, task, err=None):
23
- # repr(task) is perhaps more useful than task.name in general,
24
- # but in context of a tutorial the extra noise is unhelpful.
25
- if err is not None:
26
- e("%s: %s %s", msg, task.name, repr(err))
27
- traceback.print_exception(type(err), err, err.__traceback__)
28
- else:
29
- e("%s: %s", msg, task.name)
30
-
31
- def nursery_end(self, task, exception):
32
- if isinstance(exception, Exception):
33
- self.etasks.add(task)
34
- self._print_with_task("*** task excepted", task, exception)
35
-
36
- def before_task_step(self, task):
37
- if isinstance(task._next_send, Error) and isinstance(task._next_send.error, Exception):
38
- self._print_with_task("*** step resume ERROR", task, task._next_send.error)
39
- self.etasks.add(task)
40
- elif moat.kill: # pylint: disable=c-extension-no-member # OH COME ON
41
- self._print_with_task("*** step resume", task)
42
-
43
- def task_scheduled(self, task):
44
- e("SCHED %r", task)
45
-
46
- def task_exited(self, task):
47
- self._print_with_task("*** task exited", task)
48
- self.etasks.discard(task)
49
-
50
- def before_io_wait(self, timeout):
51
- if timeout > 10000 and self.etasks:
52
- e("\n\n\n\n\n\n\n\n\n\n")
53
- e("*** ERROR: lock-out, killing off error tasks")
54
- e("\n\n\n\n")
55
- for t in self.etasks:
56
- if t._next_send_fn is None:
57
- self._print_with_task("!!! Killing", t)
58
- t._runner.reschedule(t, Error(RuntimeError("*** Locked ***")))
59
- else:
60
- self._print_with_task("??? already scheduled", t)
61
-
62
-
63
- # trio.run(main_, instruments=[Tracer()])