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
debian/control DELETED
@@ -1,43 +0,0 @@
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.
@@ -1,201 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- #
4
- # Documentation build configuration file, created by
5
- # sphinx-quickstart on Sat Jan 21 19:11:14 2017.
6
- #
7
- # This file is execfile()d with the current directory set to its
8
- # containing dir.
9
- #
10
- # Note that not all possible configuration values are present in this
11
- # autogenerated file.
12
- #
13
- # All configuration values have a default; values that are commented out
14
- # serve to show the default.
15
-
16
- # If extensions (or modules to document with autodoc) are in another directory,
17
- # add these directories to sys.path here. If the directory is relative to the
18
- # documentation root, use os.path.abspath to make it absolute, like shown here.
19
- #
20
- import os
21
- import sys
22
-
23
- # So autodoc can import our package
24
- sys.path.insert(0, os.path.abspath("../.."))
25
-
26
- # Warn about all references to unknown targets
27
- nitpicky = True
28
- # Except for these ones, which we expect to point to unknown targets:
29
- nitpick_ignore = [
30
- # Format is ("sphinx reference type", "string"), e.g.:
31
- ("py:obj", "bytes-like"),
32
- ("py:class", "RangeSet"),
33
- ("py:class", "Any"),
34
- ]
35
-
36
- autodoc_inherit_docstrings = False
37
-
38
- # -- General configuration ------------------------------------------------
39
-
40
- # If your documentation needs a minimal Sphinx version, state it here.
41
- #
42
- # needs_sphinx = '1.0'
43
-
44
- # Add any Sphinx extension module names here, as strings. They can be
45
- # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
46
- # ones.
47
- extensions = [
48
- "sphinx.ext.autodoc",
49
- "sphinx.ext.intersphinx",
50
- "sphinx.ext.coverage",
51
- "sphinx.ext.napoleon",
52
- "sphinxcontrib_trio",
53
- ]
54
-
55
- intersphinx_mapping = {
56
- "python": ("https://docs.python.org/3", None),
57
- "trio": ("https://trio.readthedocs.io/en/stable", None),
58
- }
59
-
60
- autodoc_member_order = "bysource"
61
-
62
- # Add any paths that contain templates here, relative to this directory.
63
- templates_path = []
64
-
65
- # The suffix(es) of source filenames.
66
- # You can specify multiple suffix as a list of string:
67
- #
68
- # source_suffix = ['.rst', '.md']
69
- source_suffix = ".rst"
70
-
71
- # The master toctree document.
72
- master_doc = "index"
73
-
74
- # General information about the project.
75
- project = "MoaT-KV"
76
- copyright = "The MoaT-KV authors"
77
- author = "The MoaT-KV authors"
78
-
79
- # The version info for the project you're documenting, acts as replacement for
80
- # |version| and |release|, also used in various other places throughout the
81
- # built documents.
82
- #
83
- # The short X.Y version.
84
- import pkg_resources
85
-
86
- version = pkg_resources.get_distribution("moat.kv")._version
87
-
88
- # The full version, including alpha/beta/rc tags.
89
- release = version
90
-
91
- # The language for content autogenerated by Sphinx. Refer to documentation
92
- # for a list of supported languages.
93
- #
94
- # This is also used if you do content translation via gettext catalogs.
95
- # Usually you set "language" from the command line for these cases.
96
- language = None
97
-
98
- # List of patterns, relative to source directory, that match files and
99
- # directories to ignore when looking for source files.
100
- # This patterns also effect to html_static_path and html_extra_path
101
- exclude_patterns = []
102
-
103
- # The name of the Pygments (syntax highlighting) style to use.
104
- pygments_style = "sphinx"
105
-
106
- # The default language for :: blocks
107
- highlight_language = "python3"
108
-
109
- # If true, `todo` and `todoList` produce output, else they produce nothing.
110
- todo_include_todos = False
111
-
112
-
113
- # -- Options for HTML output ----------------------------------------------
114
-
115
- # The theme to use for HTML and HTML Help pages. See the documentation for
116
- # a list of builtin themes.
117
- #
118
- # html_theme = 'alabaster'
119
-
120
- # We have to set this ourselves, not only because it's useful for local
121
- # testing, but also because if we don't then RTD will throw away our
122
- # html_theme_options.
123
- import sphinx_rtd_theme
124
-
125
- html_theme = "sphinx_rtd_theme"
126
- html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
127
-
128
- # Theme options are theme-specific and customize the look and feel of a theme
129
- # further. For a list of options available for each theme, see the
130
- # documentation.
131
- #
132
- html_theme_options = {
133
- # default is 2
134
- # show deeper nesting in the RTD theme's sidebar TOC
135
- # https://stackoverflow.com/questions/27669376/
136
- # I'm not 100% sure this actually does anything with our current
137
- # versions/settings...
138
- "navigation_depth": 4,
139
- "logo_only": True,
140
- }
141
-
142
- # Add any paths that contain custom static files (such as style sheets) here,
143
- # relative to this directory. They are copied after the builtin static files,
144
- # so a file named "default.css" will overwrite the builtin "default.css".
145
- html_static_path = ["_static"]
146
-
147
-
148
- # -- Options for HTMLHelp output ------------------------------------------
149
-
150
- # Output file base name for HTML help builder.
151
- htmlhelp_basename = "moat.kv-doc"
152
-
153
-
154
- # -- Options for LaTeX output ---------------------------------------------
155
-
156
- latex_elements = {
157
- # The paper size ('letterpaper' or 'a4paper').
158
- #
159
- # 'papersize': 'letterpaper',
160
- # The font size ('10pt', '11pt' or '12pt').
161
- #
162
- # 'pointsize': '10pt',
163
- # Additional stuff for the LaTeX preamble.
164
- #
165
- # 'preamble': '',
166
- # Latex figure (float) alignment
167
- #
168
- # 'figure_align': 'htbp',
169
- }
170
-
171
- # Grouping the document tree into LaTeX files. List of tuples
172
- # (source start file, target name, title,
173
- # author, documentclass [howto, manual, or own class]).
174
- latex_documents = [
175
- (master_doc, "moat.kv.tex", "Trio Documentation", author, "manual"),
176
- ]
177
-
178
-
179
- # -- Options for manual page output ---------------------------------------
180
-
181
- # One entry per manual page. List of tuples
182
- # (source start file, name, description, authors, manual section).
183
- man_pages = [(master_doc, "moat.kv", "MoaT-KV Documentation", [author], 1)]
184
-
185
-
186
- # -- Options for Texinfo output -------------------------------------------
187
-
188
- # Grouping the document tree into Texinfo files. List of tuples
189
- # (source start file, target name, title, author,
190
- # dir menu entry, description, category)
191
- texinfo_documents = [
192
- (
193
- master_doc,
194
- "moat.kv",
195
- "MoaT-KV Documentation",
196
- author,
197
- "MoaT-KV",
198
- "A distributed no-master key-value store",
199
- "Miscellaneous",
200
- ),
201
- ]
@@ -1,45 +0,0 @@
1
- #!/usr/bin/python3
2
-
3
- # Batch-convert data. In this case I had some entries which were stored as
4
- # a list, but using Path made much more sense (esp when you need to
5
- # view/edit the yaml export).
6
-
7
- import anyio
8
- from moat.kv.client import open_client
9
- from moat.util import P, yload, Path
10
- import asyncclick as click
11
-
12
-
13
- def conv(m, s: str) -> bool:
14
- try:
15
- d = m.value[s]
16
- except KeyError:
17
- return 0
18
- if isinstance(d, Path):
19
- return 0
20
- if not isinstance(d, Sequence):
21
- return 0
22
- d = Path.build(d)
23
- m.value[s] = d
24
- return 1
25
-
26
-
27
- @click.command()
28
- @click.argument("path", type=P)
29
- @click.argument("keys", type=str, nargs=-1)
30
- async def main(path, keys):
31
- if not keys:
32
- keys = "src dest dst state".split()
33
- with open("/etc/moat.kv.cfg") as cff:
34
- cfg = yload(cff)
35
- async with open_client(**cfg) as client:
36
- async for m in client.get_tree(path, nchain=2):
37
- n = 0
38
- for k in keys:
39
- n += conv(m, k)
40
- if n:
41
- await client.set(ORIG + m.path, value=m.value, chain=m.chain)
42
-
43
-
44
- if __name__ == "__main__":
45
- main()
@@ -1,19 +0,0 @@
1
- # pylint: disable=W0703,C0103
2
- from __future__ import annotations
3
-
4
- __path__ = __import__("pkgutil").extend_path(__path__, __name__)
5
-
6
- try:
7
- import warning
8
- import pkg_resources # part of setuptools
9
-
10
- with warnings.filterwarnings("ignore"):
11
- _version = pkg_resources.require("moat.kv")[0].version
12
- del pkg_resources
13
- del warnings
14
-
15
- _version_tuple = tuple(int(x) for x in _version.split("."))
16
-
17
- except Exception: # pragma: no cover
18
- _version = "0.0.1"
19
- _version_tuple = (0, 0, 1)
@@ -1,93 +0,0 @@
1
- conn:
2
- # client: controls how to talk to the MoaT-KV server
3
- host: localhost
4
- port: 27586
5
- ssl: false
6
- # ssl:
7
- # cert: '/path/to/cert.pem',key='/path/to/cert.key'
8
- init_timeout: 5
9
- # time to wait for connection plus greeting
10
- auth: null
11
- # no auth used by default
12
- name: null
13
- # defaults to a seqnum
14
- config:
15
- prefix: !P :.moat.kv.config
16
- errors:
17
- prefix: !P :.moat.kv.error
18
- codes:
19
- prefix: !P :.moat.kv.code.proc
20
- modules:
21
- prefix: !P :.moat.kv.code.module
22
- runner: # for moat.kv.runner.RunnerRoot
23
- # storage for runnable commands
24
- prefix: !P :.moat.kv.run"
25
- # storage for runner states
26
- state: !P :.moat.kv.state"
27
-
28
- name: "run"
29
-
30
- start_delay: 1
31
- # time to wait between job starts. Not optional.
32
-
33
- ping: -15
34
- # set an I-am-running message every those-many seconds
35
- # positive: set in moat.kv, negative: broadcast to :moat.kv.run tag
36
-
37
- actor:
38
- # Actor config, required for Runner
39
- cycle: 20
40
- nodes: -1
41
- splits: 5
42
- n_hosts: 3
43
- version: 1
44
- sub:
45
- # tags for various runner modes
46
- group: "any"
47
- single: "at"
48
- all: "all"
49
- server:
50
- # server-side configuration
51
- buffer: 10
52
- # per-stream buffer
53
-
54
- backend: "mqtt"
55
- # default
56
- mqtt:
57
- uri: "mqtt://localhost:1883"
58
-
59
- # event message path/topic prefix
60
- root: !P moat.kv
61
-
62
- paranoia: False
63
- # typecheck server-to-server updates?
64
- #
65
- # which addresses/ports to accept MoaT-KV connections on
66
- bind: [{}]
67
- bind_default:
68
- # default values for all elements of "bind"
69
- host: "localhost"
70
- port: PORT
71
- ssl: False
72
- change:
73
- length: 5
74
- # chain length: use max nr of network sections +1
75
- ping:
76
- cycle: 10
77
- gap: 2
78
- # asyncactor config timing for server sync
79
- # ping also controls minimum server startup time
80
- delete:
81
- # asyncactor config timing for deletion
82
- cycle: 100
83
- gap: 10
84
- version: 1
85
- paranoia: false
86
- # typecheck server>server updates?
87
-
88
- # how does a new server reach existing nodes, to download state?
89
- domain: null
90
- # domain in which to look up node names, if not in hostmap
91
- hostmap: # map MoaT-KV server names to connect destinations
92
- test1: ["localhost", 27586]
93
- test2: ["does-not-exist.invalid", 27586]
@@ -1,91 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Basic DistKV support
4
-
5
- """
6
-
7
- from __future__ import annotations
8
-
9
- import logging
10
-
11
- import asyncclick as click
12
- from moat.util import attrdict, combine_dict, load_subgroup, CFG, ensure_cfg
13
-
14
- from moat.kv.auth import gen_auth
15
- from moat.kv.client import client_scope
16
-
17
- logger = logging.getLogger(__name__)
18
-
19
-
20
- ensure_cfg("moat.kv")
21
-
22
-
23
- class NullObj:
24
- """
25
- This helper defers raising an exception until one of its attributes is
26
- actually accessed.
27
- """
28
-
29
- def __init__(self, exc):
30
- self._exc = exc
31
-
32
- def __call__(self, *a, **kw):
33
- raise self._exc
34
-
35
- def __await__(self):
36
- raise self._exc
37
-
38
- def __getattr__(self, k):
39
- if k[0] == "_" and k not in ("_request", "_cfg"):
40
- return object.__getattribute__(self, k)
41
- raise self._exc
42
-
43
-
44
- @load_subgroup(sub_pre="moat.kv.command", sub_post="cli", ext_pre="moat.kv", ext_post="_main.cli")
45
- @click.option("-h", "--host", default=None, help=f"Host to use. Default: {CFG.kv.conn.host}")
46
- @click.option(
47
- "-p",
48
- "--port",
49
- type=int,
50
- default=None,
51
- help=f"Port to use. Default: {CFG.kv.conn.port}",
52
- )
53
- @click.option(
54
- "-a",
55
- "--auth",
56
- type=str,
57
- default=None,
58
- help="Auth params. =file or 'type param=value…' Default: _anon",
59
- )
60
- @click.option("-m", "--metadata", is_flag=True, help="Include/print metadata.")
61
- @click.pass_context
62
- async def cli(ctx, host, port, auth, metadata):
63
- """The MoaT Key-Value subsystem.
64
-
65
- All commands (except 'server' and 'dump') connect to a MoaT-KV server.
66
- """
67
- obj = ctx.obj
68
- cfg = attrdict()
69
- if host is not None:
70
- cfg.host = host
71
- if port is not None:
72
- cfg.port = port
73
-
74
- if auth is not None:
75
- cfg.auth = gen_auth(auth)
76
- if obj.DEBUG:
77
- cfg.auth._DEBUG = True
78
-
79
- cfg = combine_dict(attrdict(kv=attrdict(conn=cfg)), obj.cfg, cls=attrdict)
80
-
81
- obj.meta = 3 if metadata else False
82
-
83
- try:
84
- if ctx.invoked_subcommand in {None, "server", "dump"}:
85
- obj.client = NullObj(RuntimeError("Not a client command"))
86
- else:
87
- obj.client = await client_scope(**cfg.kv)
88
- except OSError as exc:
89
- obj.client = NullObj(exc)
90
- else:
91
- logger.debug("Connected.")
@@ -1,98 +0,0 @@
1
- """
2
- This module implements a :class:`asyncactor.Actor` which works on top of
3
- a MoaT-KV client.
4
- """
5
- from __future__ import annotations
6
-
7
- from asyncactor import Actor
8
- from asyncactor.abc import MonitorStream, Transport
9
-
10
- __all__ = [
11
- "ClientActor",
12
- "ActorState",
13
- "BrokenState",
14
- "DetachedState",
15
- "PartialState",
16
- "CompleteState",
17
- ]
18
-
19
-
20
- class ClientActor(Actor):
21
- def __init__(self, client, *a, topic, **kw):
22
- super().__init__(ClientTransport(client, topic), *a, **kw)
23
-
24
-
25
- class ClientTransport(Transport):
26
- """
27
- This class exports the client's direct messaging interface to the
28
- actor.
29
- """
30
-
31
- def __init__(self, client, topic):
32
- self.client = client
33
- self.topic = topic
34
-
35
- def monitor(self):
36
- return ClientMonitor(self)
37
-
38
- async def send(self, payload):
39
- await self.client.msg_send(self.topic, payload)
40
-
41
-
42
- class ClientMonitor(MonitorStream):
43
- _mon1 = None
44
- _mon2 = None
45
- _it = None
46
-
47
- async def __aenter__(self):
48
- self._mon1 = self.transport.client.msg_monitor(self.transport.topic)
49
- self._mon2 = await self._mon1.__aenter__()
50
- return self
51
-
52
- async def __aexit__(self, *tb):
53
- return await self._mon1.__aexit__(*tb)
54
-
55
- def __aiter__(self):
56
- self._it = self._mon2.__aiter__()
57
- return self
58
-
59
- async def __anext__(self):
60
- msg = await self._it.__anext__()
61
- return msg.data
62
-
63
-
64
- # The following events are used by Runner etc. to notify running jobs
65
- # about the current connectivity state.
66
- #
67
- class ActorState:
68
- """base class for states"""
69
-
70
- def __init__(self, msg=None):
71
- self.msg = msg
72
-
73
- def __repr__(self):
74
- return "<%s:%r>" % (self.__class__.__name__, self.msg)
75
-
76
-
77
- class BrokenState(ActorState):
78
- """I have no idea what's happening, probably nothing good"""
79
-
80
- pass
81
-
82
-
83
- class DetachedState(ActorState):
84
- """I am detached, my actor group is not visible"""
85
-
86
- pass
87
-
88
-
89
- class PartialState(ActorState):
90
- """Some but not all members of my actor group are visible"""
91
-
92
- pass
93
-
94
-
95
- class CompleteState(ActorState):
96
- """All members of my actor group are visible"""
97
-
98
- pass