moat-kv 0.70.22__py3-none-any.whl → 0.70.23__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.
- moat/kv/__init__.py +1 -0
- moat/kv/_cfg.yaml +97 -0
- moat/kv/_main.py +6 -9
- moat/kv/client.py +34 -50
- moat/kv/code.py +10 -3
- moat/kv/codec.py +1 -0
- moat/kv/config.py +2 -0
- moat/kv/data.py +8 -7
- moat/kv/errors.py +17 -9
- moat/kv/exceptions.py +1 -7
- moat/kv/model.py +16 -24
- moat/kv/runner.py +38 -35
- moat/kv/server.py +86 -90
- moat/kv/types.py +5 -8
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.23.dist-info}/METADATA +15 -18
- moat_kv-0.70.23.dist-info/RECORD +19 -0
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.23.dist-info}/WHEEL +1 -1
- moat_kv-0.70.23.dist-info/licenses/LICENSE.txt +14 -0
- moat/kv/_config.yaml +0 -98
- moat/kv/actor/__init__.py +0 -97
- moat/kv/actor/deletor.py +0 -137
- moat/kv/auth/__init__.py +0 -446
- moat/kv/auth/_test.py +0 -172
- moat/kv/auth/password.py +0 -232
- moat/kv/auth/root.py +0 -56
- moat/kv/backend/__init__.py +0 -66
- moat/kv/backend/mqtt.py +0 -74
- moat/kv/backend/serf.py +0 -44
- moat/kv/command/__init__.py +0 -1
- moat/kv/command/acl.py +0 -174
- moat/kv/command/auth.py +0 -258
- moat/kv/command/code.py +0 -306
- moat/kv/command/codec.py +0 -190
- moat/kv/command/data.py +0 -274
- moat/kv/command/dump/__init__.py +0 -141
- moat/kv/command/error.py +0 -156
- moat/kv/command/internal.py +0 -257
- moat/kv/command/job.py +0 -438
- moat/kv/command/log.py +0 -52
- moat/kv/command/server.py +0 -115
- moat/kv/command/type.py +0 -203
- moat/kv/mock/__init__.py +0 -97
- moat/kv/mock/mqtt.py +0 -164
- moat/kv/mock/serf.py +0 -253
- moat/kv/mock/tracer.py +0 -65
- moat/kv/obj/__init__.py +0 -636
- moat/kv/obj/command.py +0 -246
- moat_kv-0.70.22.dist-info/LICENSE +0 -3
- moat_kv-0.70.22.dist-info/LICENSE.APACHE2 +0 -202
- moat_kv-0.70.22.dist-info/LICENSE.MIT +0 -20
- moat_kv-0.70.22.dist-info/RECORD +0 -49
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.23.dist-info}/top_level.txt +0 -0
moat/kv/_config.yaml
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
kv:
|
2
|
-
conn:
|
3
|
-
# client: controls how to talk to the MoaT-KV server
|
4
|
-
host: localhost
|
5
|
-
port: 27586
|
6
|
-
ssl: false
|
7
|
-
# ssl:
|
8
|
-
# cert: '/path/to/cert.pem',key='/path/to/cert.key'
|
9
|
-
init_timeout: 5
|
10
|
-
# time to wait for connection plus greeting
|
11
|
-
auth: null
|
12
|
-
# no auth used by default
|
13
|
-
name: null
|
14
|
-
# defaults to a seqnum
|
15
|
-
config:
|
16
|
-
prefix: !P :.moat.kv.config
|
17
|
-
errors:
|
18
|
-
prefix: !P :.moat.kv.error
|
19
|
-
codes:
|
20
|
-
prefix: !P :.moat.kv.code.proc
|
21
|
-
modules:
|
22
|
-
prefix: !P :.moat.kv.code.module
|
23
|
-
runner: # for moat.kv.runner.RunnerRoot
|
24
|
-
# storage for runnable commands
|
25
|
-
prefix: !P :.moat.kv.run"
|
26
|
-
# storage for runner states
|
27
|
-
state: !P :.moat.kv.state"
|
28
|
-
|
29
|
-
name: "run"
|
30
|
-
# Serf event name, suffixed by subpath
|
31
|
-
|
32
|
-
start_delay: 1
|
33
|
-
# time to wait between job starts. Not optional.
|
34
|
-
|
35
|
-
ping: -15
|
36
|
-
# set an I-am-running message every those-many seconds
|
37
|
-
# positive: set in moat.kv, negative: broadcast to :moat.kv.run tag
|
38
|
-
|
39
|
-
actor:
|
40
|
-
# Actor config, required for Runner
|
41
|
-
cycle: 20
|
42
|
-
nodes: -1
|
43
|
-
splits: 5
|
44
|
-
n_hosts: 3
|
45
|
-
version: 1
|
46
|
-
sub:
|
47
|
-
# tags for various runner modes
|
48
|
-
group: "any"
|
49
|
-
single: "at"
|
50
|
-
all: "all"
|
51
|
-
server:
|
52
|
-
# server-side configuration
|
53
|
-
buffer: 10
|
54
|
-
# per-stream buffer
|
55
|
-
|
56
|
-
backend: "mqtt"
|
57
|
-
# default
|
58
|
-
mqtt:
|
59
|
-
uri: "mqtt://localhost:1883"
|
60
|
-
serf:
|
61
|
-
host: "localhost"
|
62
|
-
port: 7373
|
63
|
-
|
64
|
-
# event message path/topic prefix
|
65
|
-
root: !P moat.kv
|
66
|
-
|
67
|
-
paranoia: False
|
68
|
-
# typecheck server-to-server updates?
|
69
|
-
#
|
70
|
-
# which addresses/ports to accept MoaT-KV connections on
|
71
|
-
bind: [{}]
|
72
|
-
bind_default:
|
73
|
-
# default values for all elements of "bind"
|
74
|
-
host: "localhost"
|
75
|
-
port: PORT
|
76
|
-
ssl: False
|
77
|
-
change:
|
78
|
-
length: 5
|
79
|
-
# chain length: use max nr of network sections +1
|
80
|
-
ping:
|
81
|
-
cycle: 10
|
82
|
-
gap: 2
|
83
|
-
# asyncserf.Actor config timing for server sync
|
84
|
-
# ping also controls minimum server startup time
|
85
|
-
delete:
|
86
|
-
# asyncserf.Actor config timing for deletion
|
87
|
-
cycle: 100
|
88
|
-
gap: 10
|
89
|
-
version: 1
|
90
|
-
paranoia: false
|
91
|
-
# typecheck server>server updates?
|
92
|
-
|
93
|
-
# how does a new server reach existing nodes, to download state?
|
94
|
-
domain: null
|
95
|
-
# domain in which to look up node names, if not in hostmap
|
96
|
-
hostmap: # map MoaT-KV server names to connect destinations
|
97
|
-
test1: ["localhost", 27586]
|
98
|
-
test2: ["does-not-exist.invalid", 27586]
|
moat/kv/actor/__init__.py
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
This module implements a :class:`asyncactor.Actor` which works on top of
|
3
|
-
a MoaT-KV client.
|
4
|
-
"""
|
5
|
-
|
6
|
-
from asyncactor import Actor # noqa
|
7
|
-
from asyncactor.abc import MonitorStream, Transport
|
8
|
-
|
9
|
-
__all__ = [
|
10
|
-
"ClientActor",
|
11
|
-
"ActorState",
|
12
|
-
"BrokenState",
|
13
|
-
"DetachedState",
|
14
|
-
"PartialState",
|
15
|
-
"CompleteState",
|
16
|
-
]
|
17
|
-
|
18
|
-
|
19
|
-
class ClientActor(Actor):
|
20
|
-
def __init__(self, client, *a, topic, **kw):
|
21
|
-
super().__init__(ClientTransport(client, topic), *a, **kw)
|
22
|
-
|
23
|
-
|
24
|
-
class ClientTransport(Transport):
|
25
|
-
"""
|
26
|
-
This class exports the client's direct messaging interface to the
|
27
|
-
actor.
|
28
|
-
"""
|
29
|
-
|
30
|
-
def __init__(self, client, topic):
|
31
|
-
self.client = client
|
32
|
-
self.topic = topic
|
33
|
-
|
34
|
-
def monitor(self):
|
35
|
-
return ClientMonitor(self)
|
36
|
-
|
37
|
-
async def send(self, payload):
|
38
|
-
await self.client.msg_send(self.topic, payload)
|
39
|
-
|
40
|
-
|
41
|
-
class ClientMonitor(MonitorStream):
|
42
|
-
_mon1 = None
|
43
|
-
_mon2 = None
|
44
|
-
_it = None
|
45
|
-
|
46
|
-
async def __aenter__(self):
|
47
|
-
self._mon1 = self.transport.client.msg_monitor(self.transport.topic)
|
48
|
-
self._mon2 = await self._mon1.__aenter__()
|
49
|
-
return self
|
50
|
-
|
51
|
-
async def __aexit__(self, *tb):
|
52
|
-
return await self._mon1.__aexit__(*tb)
|
53
|
-
|
54
|
-
def __aiter__(self):
|
55
|
-
self._it = self._mon2.__aiter__()
|
56
|
-
return self
|
57
|
-
|
58
|
-
async def __anext__(self):
|
59
|
-
msg = await self._it.__anext__()
|
60
|
-
return msg.data
|
61
|
-
|
62
|
-
|
63
|
-
# The following events are used by Runner etc. to notify running jobs
|
64
|
-
# about the current connectivity state.
|
65
|
-
#
|
66
|
-
class ActorState:
|
67
|
-
"""base class for states"""
|
68
|
-
|
69
|
-
def __init__(self, msg=None):
|
70
|
-
self.msg = msg
|
71
|
-
|
72
|
-
def __repr__(self):
|
73
|
-
return "<%s:%r>" % (self.__class__.__name__, self.msg)
|
74
|
-
|
75
|
-
|
76
|
-
class BrokenState(ActorState):
|
77
|
-
"""I have no idea what's happening, probably nothing good"""
|
78
|
-
|
79
|
-
pass
|
80
|
-
|
81
|
-
|
82
|
-
class DetachedState(ActorState):
|
83
|
-
"""I am detached, my actor group is not visible"""
|
84
|
-
|
85
|
-
pass
|
86
|
-
|
87
|
-
|
88
|
-
class PartialState(ActorState):
|
89
|
-
"""Some but not all members of my actor group are visible"""
|
90
|
-
|
91
|
-
pass
|
92
|
-
|
93
|
-
|
94
|
-
class CompleteState(ActorState):
|
95
|
-
"""All members of my actor group are visible"""
|
96
|
-
|
97
|
-
pass
|
moat/kv/actor/deletor.py
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
This module implements additional code for the server-side DeleteActor,
|
3
|
-
which is used to clean up the list of deleted nodes.
|
4
|
-
"""
|
5
|
-
|
6
|
-
import weakref
|
7
|
-
from collections import deque
|
8
|
-
|
9
|
-
import anyio
|
10
|
-
from asyncactor import Actor, PingEvent, TagEvent
|
11
|
-
from asyncactor.backend import get_transport
|
12
|
-
|
13
|
-
TAGS = 4
|
14
|
-
|
15
|
-
|
16
|
-
class DeleteActor:
|
17
|
-
_enabled = None
|
18
|
-
|
19
|
-
def __init__(self, server):
|
20
|
-
self._server = weakref.ref(server)
|
21
|
-
self.deleted = deque()
|
22
|
-
self.tags = []
|
23
|
-
self.actor = None
|
24
|
-
|
25
|
-
self.max_seen = 0
|
26
|
-
self.n_tags = 0
|
27
|
-
self.n_pings = 0
|
28
|
-
self.n_nodes = 0
|
29
|
-
|
30
|
-
@property
|
31
|
-
def server(self):
|
32
|
-
return self._server()
|
33
|
-
|
34
|
-
async def tock_me(self):
|
35
|
-
"""
|
36
|
-
Add the current tock to our buffer.
|
37
|
-
|
38
|
-
This is updated whenever a new leader is selected.
|
39
|
-
"""
|
40
|
-
self.tags.append(self.server.tock)
|
41
|
-
self.tags = self.tags[-TAGS:]
|
42
|
-
await self.actor.set_value((self.tags[0], self.tags[-1]))
|
43
|
-
|
44
|
-
def add_deleted(self, nodes: "NodeSet"): # noqa: F821
|
45
|
-
"""
|
46
|
-
These nodes are deleted. Remember them for some time.
|
47
|
-
"""
|
48
|
-
if self.n_nodes == 0:
|
49
|
-
return
|
50
|
-
self.deleted.append((self.server.tock, nodes))
|
51
|
-
|
52
|
-
def purge_to(self, tock):
|
53
|
-
"""
|
54
|
-
Sufficient time has passed since this tock was seen, while all
|
55
|
-
Delete actor nodes were active. Finally flush the entries that have
|
56
|
-
been deleted before it.
|
57
|
-
"""
|
58
|
-
while self.deleted and self.deleted[0][0] < tock:
|
59
|
-
d = self.deleted.popleft()
|
60
|
-
self.server.purge_deleted(d[1])
|
61
|
-
|
62
|
-
async def enable(self, n):
|
63
|
-
"""
|
64
|
-
Enable this actor, as a group of N.
|
65
|
-
"""
|
66
|
-
if self.actor is None:
|
67
|
-
self._enabled = True
|
68
|
-
else:
|
69
|
-
await self.actor.enable(n)
|
70
|
-
self.n_tags = 0
|
71
|
-
self.n_pings = 0
|
72
|
-
self.n_nodes = n
|
73
|
-
|
74
|
-
async def disable(self, n: int = 0):
|
75
|
-
"""
|
76
|
-
Disable this actor. It will still listen, and require N Delete
|
77
|
-
actor members in order to flush its deletion entries.
|
78
|
-
|
79
|
-
Completely disable deletion flushing by passing n=0.
|
80
|
-
"""
|
81
|
-
if self.actor is None:
|
82
|
-
self._enabled = False
|
83
|
-
else:
|
84
|
-
await self.actor.disable()
|
85
|
-
self.n_tags = 0
|
86
|
-
self.n_pings = 0
|
87
|
-
self.n_nodes = n
|
88
|
-
|
89
|
-
async def run(self, evt: anyio.abc.Event = None):
|
90
|
-
"""
|
91
|
-
The task that monitors the Delete actor.
|
92
|
-
"""
|
93
|
-
try:
|
94
|
-
T = get_transport("moat_kv")
|
95
|
-
async with Actor(
|
96
|
-
T(self.server.backend, *self.server.cfg.server.root, "del"),
|
97
|
-
name=self.server.node.name,
|
98
|
-
cfg=self.server.cfg.server.delete,
|
99
|
-
enabled=False,
|
100
|
-
) as actor:
|
101
|
-
self.actor = actor
|
102
|
-
if self._enabled is not None:
|
103
|
-
if self._enabled:
|
104
|
-
await actor.enable()
|
105
|
-
else:
|
106
|
-
await actor.disable()
|
107
|
-
if evt is not None:
|
108
|
-
evt.set()
|
109
|
-
async for evt in actor:
|
110
|
-
if isinstance(evt, PingEvent):
|
111
|
-
val = evt.value
|
112
|
-
if val is None:
|
113
|
-
self.n_pings = self.n_tags = 0
|
114
|
-
continue
|
115
|
-
if len(evt.msg.history) < self.n_nodes:
|
116
|
-
self.n_pings = self.n_tags = 0
|
117
|
-
continue
|
118
|
-
self.n_pings += 1
|
119
|
-
if self.n_pings > self.n_nodes:
|
120
|
-
mx, self.max_seen = (
|
121
|
-
self.max_seen,
|
122
|
-
max(self.max_seen, val[1]),
|
123
|
-
)
|
124
|
-
if val[0] > mx > 0:
|
125
|
-
await self.server.resync_deleted(evt.msg.history)
|
126
|
-
continue
|
127
|
-
self.purge_to(val[0])
|
128
|
-
self.max_seen = max(self.max_seen, val[1])
|
129
|
-
|
130
|
-
elif isinstance(evt, TagEvent):
|
131
|
-
if actor.history_size == self.n_nodes:
|
132
|
-
self.n_tags += 1
|
133
|
-
if self.n_tags > 2:
|
134
|
-
self.purge_to(self.tags[0])
|
135
|
-
await self.tock_me()
|
136
|
-
finally:
|
137
|
-
self.actor = None
|