leanqueue 0.2.1__cp38-abi3-win32.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.
- leanqueue/__init__.py +5 -0
- leanqueue/leanqueue.pyd +0 -0
- leanqueue-0.2.1.dist-info/METADATA +36 -0
- leanqueue-0.2.1.dist-info/RECORD +19 -0
- leanqueue-0.2.1.dist-info/WHEEL +4 -0
- leanqueue-0.2.1.dist-info/entry_points.txt +3 -0
- leanqueue-0.2.1.dist-info/licenses/LICENSE +21 -0
- leanqueue-0.2.1.dist-info/sboms/leanqueue.cyclonedx.json +1049 -0
- leanqueue_server/__init__.py +14 -0
- leanqueue_server/cli.py +71 -0
- leanqueue_server/client.py +216 -0
- leanqueue_server/leanqueue.proto +99 -0
- leanqueue_server/leanqueue_pb2.py +82 -0
- leanqueue_server/leanqueue_pb2_grpc.py +662 -0
- leanqueue_server/serve.py +529 -0
- leanqueue_server/serve_grpc.py +340 -0
- leanqueue_server/serve_guardrails.py +441 -0
- leanqueue_server/service.py +433 -0
- leanqueuedb.py +590 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""LeanQueue servers, shipped in the wheel and installed with extras:
|
|
2
|
+
|
|
3
|
+
pip install "leanqueue[server]" # REST (FastAPI/uvicorn): leanqueue-serve
|
|
4
|
+
pip install "leanqueue[grpc]" # gRPC: leanqueue-grpc, leanqueue_server.client.LeanQueueClient
|
|
5
|
+
|
|
6
|
+
Modules: serve (REST app), serve_grpc (gRPC servicer), service (operations shared by
|
|
7
|
+
both), serve_guardrails (request limits), client (REST and gRPC clients),
|
|
8
|
+
leanqueue.proto + generated stubs. Nothing here is imported by `import leanqueue` or
|
|
9
|
+
`import leanqueuedb`; the embedded library never loads the server stack.
|
|
10
|
+
|
|
11
|
+
Trust boundary: both servers bind loopback by default and refuse a non-loopback
|
|
12
|
+
listener without a token (LEANQUEUE_API_TOKEN; gRPC also wants TLS) unless
|
|
13
|
+
LEANQUEUE_ALLOW_INSECURE=1. See CLIENT.md.
|
|
14
|
+
"""
|
leanqueue_server/cli.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Console entry points `leanqueue-serve` (REST) and `leanqueue-grpc` (gRPC).
|
|
2
|
+
|
|
3
|
+
The servers read their configuration from the environment when their module is
|
|
4
|
+
imported (LEANQUEUE_DATA_DIR, HOST/PORT, GRPC_HOST/GRPC_PORT, ...); a flag given here is
|
|
5
|
+
exported to that variable first, so flags and environment configure the same thing.
|
|
6
|
+
The bearer token is read from LEANQUEUE_API_TOKEN only: a command-line secret would
|
|
7
|
+
show up in `ps`.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import os
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _parse(prog: str, host_env: str, port_env: str, default_port: str, argv, tls=False):
|
|
17
|
+
what = "gRPC" if tls else "REST"
|
|
18
|
+
p = argparse.ArgumentParser(
|
|
19
|
+
prog=prog, description=f"Serve LeanQueue queues over {what}. Flags override the "
|
|
20
|
+
f"environment variables named in each help line.")
|
|
21
|
+
p.add_argument("--data-dir", help="broker root directory (LEANQUEUE_DATA_DIR, default "
|
|
22
|
+
"./leanqueue_data)")
|
|
23
|
+
p.add_argument("--host", help=f"bind address ({host_env}, default 127.0.0.1)")
|
|
24
|
+
p.add_argument("--port", type=int, help=f"{port_env} (default {default_port})")
|
|
25
|
+
p.add_argument("--sync-interval-ms", type=int,
|
|
26
|
+
help="LEANQUEUE_SYNC_INTERVAL_MS for the queues (default 250: background fsync within 250 ms; 0 = fsync each write)")
|
|
27
|
+
p.add_argument("--allow-insecure", action="store_true", default=None,
|
|
28
|
+
help="LEANQUEUE_ALLOW_INSECURE=1: serve a non-loopback address without "
|
|
29
|
+
"authentication (only on a trusted private network)")
|
|
30
|
+
if tls:
|
|
31
|
+
p.add_argument("--tls-cert", help="LEANQUEUE_GRPC_TLS_CERT (PEM certificate chain)")
|
|
32
|
+
p.add_argument("--tls-key", help="LEANQUEUE_GRPC_TLS_KEY (PEM private key)")
|
|
33
|
+
a = p.parse_args(argv)
|
|
34
|
+
pairs = [(a.data_dir, "LEANQUEUE_DATA_DIR"), (a.host, host_env), (a.port, port_env),
|
|
35
|
+
(a.sync_interval_ms, "LEANQUEUE_SYNC_INTERVAL_MS"),
|
|
36
|
+
("1" if a.allow_insecure else None, "LEANQUEUE_ALLOW_INSECURE")]
|
|
37
|
+
if tls:
|
|
38
|
+
pairs += [(a.tls_cert, "LEANQUEUE_GRPC_TLS_CERT"), (a.tls_key, "LEANQUEUE_GRPC_TLS_KEY")]
|
|
39
|
+
for value, name in pairs:
|
|
40
|
+
if value is not None:
|
|
41
|
+
os.environ[name] = str(value)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def rest(argv=None):
|
|
45
|
+
_parse("leanqueue-serve", "HOST", "PORT", "8004", argv)
|
|
46
|
+
try:
|
|
47
|
+
from . import serve
|
|
48
|
+
except ImportError as e:
|
|
49
|
+
sys.exit(f"leanqueue-serve needs the REST extras: pip install 'leanqueue[server]' ({e})")
|
|
50
|
+
except RuntimeError as e:
|
|
51
|
+
sys.exit(str(e))
|
|
52
|
+
try:
|
|
53
|
+
serve.check_trust_boundary(serve._HOST)
|
|
54
|
+
except RuntimeError as e:
|
|
55
|
+
sys.exit(str(e))
|
|
56
|
+
serve.main()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def grpc(argv=None):
|
|
60
|
+
_parse("leanqueue-grpc", "GRPC_HOST", "GRPC_PORT", "50054", argv, tls=True)
|
|
61
|
+
try:
|
|
62
|
+
from . import serve_grpc
|
|
63
|
+
except ImportError as e:
|
|
64
|
+
sys.exit(f"leanqueue-grpc needs the gRPC extras: pip install 'leanqueue[grpc]' ({e})")
|
|
65
|
+
except RuntimeError as e:
|
|
66
|
+
sys.exit(str(e))
|
|
67
|
+
try:
|
|
68
|
+
serve_grpc.check_trust_boundary(serve_grpc._HOST)
|
|
69
|
+
except RuntimeError as e:
|
|
70
|
+
sys.exit(str(e))
|
|
71
|
+
serve_grpc.serve()
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""Thin clients for the LeanQueue servers.
|
|
2
|
+
|
|
3
|
+
from leanqueue_server.client import LeanQueueClient, LeanQueueRestClient
|
|
4
|
+
|
|
5
|
+
with LeanQueueClient("127.0.0.1:50054") as c: # gRPC
|
|
6
|
+
c.declare("jobs")
|
|
7
|
+
c.publish("jobs", b"hello")
|
|
8
|
+
for d in c.consume("jobs", prefetch=10): # d: dict(seq, deliveries, ...)
|
|
9
|
+
handle(d["body"])
|
|
10
|
+
c.ack("jobs", [d["seq"]])
|
|
11
|
+
|
|
12
|
+
with LeanQueueRestClient("http://127.0.0.1:8004") as r: # REST (httpx)
|
|
13
|
+
r.declare("jobs")
|
|
14
|
+
r.publish("jobs", b"hello")
|
|
15
|
+
msgs = r.get("jobs", max_messages=10, wait_ms=1000)
|
|
16
|
+
|
|
17
|
+
Both return plain Python values; bodies are `bytes`. Token: pass `token=` or set
|
|
18
|
+
LEANQUEUE_API_TOKEN. Each client is safe to share across threads.
|
|
19
|
+
"""
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import base64
|
|
23
|
+
import os
|
|
24
|
+
from typing import Any, Dict, Iterator, List, Optional
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _msg(seq, deliveries, ts, body) -> Dict[str, Any]:
|
|
28
|
+
return {"seq": seq, "deliveries": deliveries, "enqueued_at_ms": ts, "body": body}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class LeanQueueClient:
|
|
32
|
+
"""gRPC client (needs the [grpc] extra)."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, target: str = "127.0.0.1:50054", *, token: Optional[str] = None,
|
|
35
|
+
tls_ca: Optional[bytes] = None, timeout: Optional[float] = 30.0,
|
|
36
|
+
max_message_bytes: int = 128 << 20):
|
|
37
|
+
import grpc
|
|
38
|
+
from . import leanqueue_pb2 as pb
|
|
39
|
+
from . import leanqueue_pb2_grpc as pb_grpc
|
|
40
|
+
|
|
41
|
+
self._pb = pb
|
|
42
|
+
opts = [("grpc.max_send_message_length", max_message_bytes),
|
|
43
|
+
("grpc.max_receive_message_length", max_message_bytes)]
|
|
44
|
+
if tls_ca is not None:
|
|
45
|
+
self._channel = grpc.secure_channel(target, grpc.ssl_channel_credentials(tls_ca), opts)
|
|
46
|
+
else:
|
|
47
|
+
self._channel = grpc.insecure_channel(target, opts)
|
|
48
|
+
self._stub = pb_grpc.LeanQueueStub(self._channel)
|
|
49
|
+
token = token or os.environ.get("LEANQUEUE_API_TOKEN")
|
|
50
|
+
self._md = [("authorization", f"Bearer {token}")] if token else None
|
|
51
|
+
self._timeout = timeout
|
|
52
|
+
|
|
53
|
+
def _call(self, name, req, timeout=None):
|
|
54
|
+
return getattr(self._stub, name)(req, timeout=timeout or self._timeout, metadata=self._md)
|
|
55
|
+
|
|
56
|
+
def wait_ready(self, timeout: float = 10.0) -> None:
|
|
57
|
+
import grpc
|
|
58
|
+
grpc.channel_ready_future(self._channel).result(timeout=timeout)
|
|
59
|
+
|
|
60
|
+
def health(self) -> Dict[str, Any]:
|
|
61
|
+
r = self._call("Health", self._pb.HealthRequest())
|
|
62
|
+
return {"ready": r.ready, "version": r.version}
|
|
63
|
+
|
|
64
|
+
def list_queues(self) -> List[str]:
|
|
65
|
+
return list(self._call("ListQueues", self._pb.ListQueuesRequest()).queues)
|
|
66
|
+
|
|
67
|
+
def declare(self, queue: str) -> bool:
|
|
68
|
+
return self._call("DeclareQueue", self._pb.QueueRequest(queue=queue)).created
|
|
69
|
+
|
|
70
|
+
def delete(self, queue: str) -> bool:
|
|
71
|
+
return self._call("DeleteQueue", self._pb.QueueRequest(queue=queue)).deleted
|
|
72
|
+
|
|
73
|
+
def stats(self, queue: str) -> Dict[str, Any]:
|
|
74
|
+
import json
|
|
75
|
+
return json.loads(self._call("Stats", self._pb.QueueRequest(queue=queue)).stats_json)
|
|
76
|
+
|
|
77
|
+
def publish(self, queue: str, body: bytes) -> int:
|
|
78
|
+
return self._call("Publish", self._pb.PublishRequest(queue=queue, body=body)).seq
|
|
79
|
+
|
|
80
|
+
def publish_batch(self, queue: str, bodies: List[bytes]) -> List[int]:
|
|
81
|
+
return list(self._call("PublishBatch",
|
|
82
|
+
self._pb.PublishBatchRequest(queue=queue, bodies=bodies)).seqs)
|
|
83
|
+
|
|
84
|
+
def get(self, queue: str, max_messages: int = 1, lease_ms: Optional[int] = None,
|
|
85
|
+
wait_ms: int = 0) -> List[Dict[str, Any]]:
|
|
86
|
+
req = self._pb.GetRequest(queue=queue, max_messages=max_messages, wait_ms=wait_ms)
|
|
87
|
+
if lease_ms is not None:
|
|
88
|
+
req.lease_ms = lease_ms
|
|
89
|
+
timeout = (self._timeout + wait_ms / 1000.0) if self._timeout else None
|
|
90
|
+
r = self._call("Get", req, timeout=timeout)
|
|
91
|
+
return [_msg(m.seq, m.deliveries, m.enqueued_at_ms, m.body) for m in r.messages]
|
|
92
|
+
|
|
93
|
+
def ack(self, queue: str, seqs: List[int]) -> int:
|
|
94
|
+
return self._call("Ack", self._pb.SeqsRequest(queue=queue, seqs=seqs)).count
|
|
95
|
+
|
|
96
|
+
def nack(self, queue: str, seqs: List[int], requeue: bool = True) -> int:
|
|
97
|
+
return self._call("Nack", self._pb.NackRequest(queue=queue, seqs=seqs,
|
|
98
|
+
drop=not requeue)).count
|
|
99
|
+
|
|
100
|
+
def extend(self, queue: str, seqs: List[int], lease_ms: Optional[int] = None) -> int:
|
|
101
|
+
req = self._pb.ExtendRequest(queue=queue, seqs=seqs)
|
|
102
|
+
if lease_ms is not None:
|
|
103
|
+
req.lease_ms = lease_ms
|
|
104
|
+
return self._call("Extend", req).count
|
|
105
|
+
|
|
106
|
+
def states(self, queue: str, seqs: List[int]) -> List[Optional[Dict[str, Any]]]:
|
|
107
|
+
out = []
|
|
108
|
+
for s in self._call("States", self._pb.SeqsRequest(queue=queue, seqs=seqs)).states:
|
|
109
|
+
out.append(None if not s.exists else {
|
|
110
|
+
"state": "in_flight" if s.in_flight else "ready", "deliveries": s.deliveries,
|
|
111
|
+
"lease_until_ms": s.lease_until_ms if s.in_flight else None})
|
|
112
|
+
return out
|
|
113
|
+
|
|
114
|
+
def purge(self, queue: str) -> None:
|
|
115
|
+
self._call("Purge", self._pb.QueueRequest(queue=queue))
|
|
116
|
+
|
|
117
|
+
def consume(self, queue: str, prefetch: int = 1, lease_ms: Optional[int] = None,
|
|
118
|
+
idle_timeout_ms: int = 0) -> Iterator[Dict[str, Any]]:
|
|
119
|
+
"""Iterate deliveries; settle each with ack/nack. Cancelling the iterator (or
|
|
120
|
+
breaking out of the loop and closing it) requeues what it still holds."""
|
|
121
|
+
req = self._pb.ConsumeRequest(queue=queue, prefetch=prefetch,
|
|
122
|
+
idle_timeout_ms=idle_timeout_ms)
|
|
123
|
+
if lease_ms is not None:
|
|
124
|
+
req.lease_ms = lease_ms
|
|
125
|
+
call = self._stub.Consume(req, metadata=self._md)
|
|
126
|
+
try:
|
|
127
|
+
for m in call:
|
|
128
|
+
yield _msg(m.seq, m.deliveries, m.enqueued_at_ms, m.body)
|
|
129
|
+
finally:
|
|
130
|
+
call.cancel()
|
|
131
|
+
|
|
132
|
+
def close(self) -> None:
|
|
133
|
+
self._channel.close()
|
|
134
|
+
|
|
135
|
+
def __enter__(self):
|
|
136
|
+
return self
|
|
137
|
+
|
|
138
|
+
def __exit__(self, *exc):
|
|
139
|
+
self.close()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class LeanQueueRestClient:
|
|
143
|
+
"""REST client (needs httpx, part of the [server] extra)."""
|
|
144
|
+
|
|
145
|
+
def __init__(self, base_url: str = "http://127.0.0.1:8004", *, token: Optional[str] = None,
|
|
146
|
+
timeout: float = 30.0, client=None):
|
|
147
|
+
import httpx
|
|
148
|
+
|
|
149
|
+
token = token or os.environ.get("LEANQUEUE_API_TOKEN")
|
|
150
|
+
headers = {"authorization": f"Bearer {token}"} if token else {}
|
|
151
|
+
self._http = client or httpx.Client(base_url=base_url, headers=headers, timeout=timeout)
|
|
152
|
+
|
|
153
|
+
def _do(self, method, path, **kw):
|
|
154
|
+
r = self._http.request(method, path, **kw)
|
|
155
|
+
r.raise_for_status()
|
|
156
|
+
return r.json()
|
|
157
|
+
|
|
158
|
+
def health(self):
|
|
159
|
+
return self._do("GET", "/health")
|
|
160
|
+
|
|
161
|
+
def list_queues(self) -> List[str]:
|
|
162
|
+
return self._do("GET", "/queues")["queues"]
|
|
163
|
+
|
|
164
|
+
def declare(self, queue: str) -> bool:
|
|
165
|
+
return self._do("PUT", f"/queues/{queue}")["created"]
|
|
166
|
+
|
|
167
|
+
def delete(self, queue: str) -> bool:
|
|
168
|
+
return self._do("DELETE", f"/queues/{queue}")["deleted"]
|
|
169
|
+
|
|
170
|
+
def stats(self, queue: str) -> Dict[str, Any]:
|
|
171
|
+
return self._do("GET", f"/queues/{queue}/stats")
|
|
172
|
+
|
|
173
|
+
def publish(self, queue: str, body: bytes) -> int:
|
|
174
|
+
return self._do("POST", f"/queues/{queue}/publish",
|
|
175
|
+
json={"body_b64": base64.b64encode(body).decode()})["seq"]
|
|
176
|
+
|
|
177
|
+
def publish_batch(self, queue: str, bodies: List[bytes]) -> List[int]:
|
|
178
|
+
msgs = [{"body_b64": base64.b64encode(b).decode()} for b in bodies]
|
|
179
|
+
return self._do("POST", f"/queues/{queue}/publish_batch", json={"messages": msgs})["seqs"]
|
|
180
|
+
|
|
181
|
+
def get(self, queue: str, max_messages: int = 1, lease_ms: Optional[int] = None,
|
|
182
|
+
wait_ms: int = 0) -> List[Dict[str, Any]]:
|
|
183
|
+
req: Dict[str, Any] = {"max_messages": max_messages, "wait_ms": wait_ms}
|
|
184
|
+
if lease_ms is not None:
|
|
185
|
+
req["lease_ms"] = lease_ms
|
|
186
|
+
r = self._do("POST", f"/queues/{queue}/get", json=req)
|
|
187
|
+
return [_msg(m["seq"], m["deliveries"], m["enqueued_at_ms"], base64.b64decode(m["body_b64"]))
|
|
188
|
+
for m in r["messages"]]
|
|
189
|
+
|
|
190
|
+
def ack(self, queue: str, seqs: List[int]) -> int:
|
|
191
|
+
return self._do("POST", f"/queues/{queue}/ack", json={"seqs": seqs})["acked"]
|
|
192
|
+
|
|
193
|
+
def nack(self, queue: str, seqs: List[int], requeue: bool = True) -> int:
|
|
194
|
+
return self._do("POST", f"/queues/{queue}/nack",
|
|
195
|
+
json={"seqs": seqs, "requeue": requeue})["nacked"]
|
|
196
|
+
|
|
197
|
+
def extend(self, queue: str, seqs: List[int], lease_ms: Optional[int] = None) -> int:
|
|
198
|
+
req: Dict[str, Any] = {"seqs": seqs}
|
|
199
|
+
if lease_ms is not None:
|
|
200
|
+
req["lease_ms"] = lease_ms
|
|
201
|
+
return self._do("POST", f"/queues/{queue}/extend", json=req)["extended"]
|
|
202
|
+
|
|
203
|
+
def states(self, queue: str, seqs: List[int]):
|
|
204
|
+
return self._do("POST", f"/queues/{queue}/states", json={"seqs": seqs})["states"]
|
|
205
|
+
|
|
206
|
+
def purge(self, queue: str) -> None:
|
|
207
|
+
self._do("POST", f"/queues/{queue}/purge")
|
|
208
|
+
|
|
209
|
+
def close(self) -> None:
|
|
210
|
+
self._http.close()
|
|
211
|
+
|
|
212
|
+
def __enter__(self):
|
|
213
|
+
return self
|
|
214
|
+
|
|
215
|
+
def __exit__(self, *exc):
|
|
216
|
+
self.close()
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// LeanQueue gRPC API. Regenerate the stubs after editing: python scripts/gen_grpc.py
|
|
2
|
+
syntax = "proto3";
|
|
3
|
+
|
|
4
|
+
package leanqueue;
|
|
5
|
+
|
|
6
|
+
service LeanQueue {
|
|
7
|
+
rpc Health(HealthRequest) returns (HealthReply);
|
|
8
|
+
rpc ListQueues(ListQueuesRequest) returns (ListQueuesReply);
|
|
9
|
+
rpc DeclareQueue(QueueRequest) returns (DeclareReply);
|
|
10
|
+
rpc DeleteQueue(QueueRequest) returns (DeleteReply);
|
|
11
|
+
// Queue statistics as a JSON object (the same dict Queue.stats() returns).
|
|
12
|
+
rpc Stats(QueueRequest) returns (StatsReply);
|
|
13
|
+
rpc Publish(PublishRequest) returns (PublishReply); // one message
|
|
14
|
+
rpc PublishBatch(PublishBatchRequest) returns (PublishBatchReply);
|
|
15
|
+
// Lease up to max_messages; wait_ms > 0 long-polls an empty queue.
|
|
16
|
+
rpc Get(GetRequest) returns (GetReply);
|
|
17
|
+
rpc Ack(SeqsRequest) returns (CountReply);
|
|
18
|
+
rpc Nack(NackRequest) returns (CountReply);
|
|
19
|
+
rpc Extend(ExtendRequest) returns (CountReply);
|
|
20
|
+
rpc States(SeqsRequest) returns (StatesReply);
|
|
21
|
+
rpc Purge(QueueRequest) returns (PurgeReply);
|
|
22
|
+
// Push deliveries, keeping at most `prefetch` delivered-but-unsettled messages
|
|
23
|
+
// outstanding (settle them with Ack/Nack). When the stream ends, messages still
|
|
24
|
+
// leased to it are requeued.
|
|
25
|
+
rpc Consume(ConsumeRequest) returns (stream Delivery);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
message HealthRequest {}
|
|
29
|
+
message HealthReply {
|
|
30
|
+
bool ready = 1;
|
|
31
|
+
string version = 2;
|
|
32
|
+
string limits_json = 3;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
message ListQueuesRequest {}
|
|
36
|
+
message ListQueuesReply { repeated string queues = 1; }
|
|
37
|
+
|
|
38
|
+
message QueueRequest { string queue = 1; }
|
|
39
|
+
message DeclareReply { bool created = 1; }
|
|
40
|
+
message DeleteReply { bool deleted = 1; }
|
|
41
|
+
message StatsReply { string stats_json = 1; }
|
|
42
|
+
message PurgeReply {}
|
|
43
|
+
|
|
44
|
+
message PublishRequest {
|
|
45
|
+
string queue = 1;
|
|
46
|
+
bytes body = 2;
|
|
47
|
+
}
|
|
48
|
+
message PublishReply { uint64 seq = 1; }
|
|
49
|
+
|
|
50
|
+
message PublishBatchRequest {
|
|
51
|
+
string queue = 1;
|
|
52
|
+
repeated bytes bodies = 2;
|
|
53
|
+
}
|
|
54
|
+
message PublishBatchReply { repeated uint64 seqs = 1; }
|
|
55
|
+
|
|
56
|
+
message GetRequest {
|
|
57
|
+
string queue = 1;
|
|
58
|
+
uint32 max_messages = 2; // 0 means 1
|
|
59
|
+
optional uint64 lease_ms = 3; // unset: the queue's default lease
|
|
60
|
+
uint64 wait_ms = 4;
|
|
61
|
+
}
|
|
62
|
+
message Delivery {
|
|
63
|
+
uint64 seq = 1;
|
|
64
|
+
uint32 deliveries = 2;
|
|
65
|
+
uint64 enqueued_at_ms = 3;
|
|
66
|
+
bytes body = 4;
|
|
67
|
+
}
|
|
68
|
+
message GetReply { repeated Delivery messages = 1; }
|
|
69
|
+
|
|
70
|
+
message SeqsRequest {
|
|
71
|
+
string queue = 1;
|
|
72
|
+
repeated uint64 seqs = 2;
|
|
73
|
+
}
|
|
74
|
+
message NackRequest {
|
|
75
|
+
string queue = 1;
|
|
76
|
+
repeated uint64 seqs = 2;
|
|
77
|
+
bool drop = 3; // false (default): requeue; true: dead-letter/drop
|
|
78
|
+
}
|
|
79
|
+
message ExtendRequest {
|
|
80
|
+
string queue = 1;
|
|
81
|
+
repeated uint64 seqs = 2;
|
|
82
|
+
optional uint64 lease_ms = 3;
|
|
83
|
+
}
|
|
84
|
+
message CountReply { uint64 count = 1; }
|
|
85
|
+
|
|
86
|
+
message MessageState {
|
|
87
|
+
bool exists = 1;
|
|
88
|
+
bool in_flight = 2;
|
|
89
|
+
uint32 deliveries = 3;
|
|
90
|
+
uint64 lease_until_ms = 4;
|
|
91
|
+
}
|
|
92
|
+
message StatesReply { repeated MessageState states = 1; }
|
|
93
|
+
|
|
94
|
+
message ConsumeRequest {
|
|
95
|
+
string queue = 1;
|
|
96
|
+
uint32 prefetch = 2; // 0 means 1
|
|
97
|
+
optional uint64 lease_ms = 3;
|
|
98
|
+
uint64 idle_timeout_ms = 4; // end the stream after this long with nothing to deliver; 0 = never
|
|
99
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: leanqueue.proto
|
|
5
|
+
# Protobuf Python Version: 7.35.0
|
|
6
|
+
"""Generated protocol buffer code."""
|
|
7
|
+
from google.protobuf import descriptor as _descriptor
|
|
8
|
+
from google.protobuf import descriptor_pool as _descriptor_pool
|
|
9
|
+
from google.protobuf import runtime_version as _runtime_version
|
|
10
|
+
from google.protobuf import symbol_database as _symbol_database
|
|
11
|
+
from google.protobuf.internal import builder as _builder
|
|
12
|
+
_runtime_version.ValidateProtobufRuntimeVersion(
|
|
13
|
+
_runtime_version.Domain.PUBLIC,
|
|
14
|
+
7,
|
|
15
|
+
35,
|
|
16
|
+
0,
|
|
17
|
+
'',
|
|
18
|
+
'leanqueue.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fleanqueue.proto\x12\tleanqueue\"\x0f\n\rHealthRequest\"B\n\x0bHealthReply\x12\r\n\x05ready\x18\x01 \x01(\x08\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x13\n\x0blimits_json\x18\x03 \x01(\t\"\x13\n\x11ListQueuesRequest\"!\n\x0fListQueuesReply\x12\x0e\n\x06queues\x18\x01 \x03(\t\"\x1d\n\x0cQueueRequest\x12\r\n\x05queue\x18\x01 \x01(\t\"\x1f\n\x0c\x44\x65\x63lareReply\x12\x0f\n\x07\x63reated\x18\x01 \x01(\x08\"\x1e\n\x0b\x44\x65leteReply\x12\x0f\n\x07\x64\x65leted\x18\x01 \x01(\x08\" \n\nStatsReply\x12\x12\n\nstats_json\x18\x01 \x01(\t\"\x0c\n\nPurgeReply\"-\n\x0ePublishRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x0c\n\x04\x62ody\x18\x02 \x01(\x0c\"\x1b\n\x0cPublishReply\x12\x0b\n\x03seq\x18\x01 \x01(\x04\"4\n\x13PublishBatchRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x0e\n\x06\x62odies\x18\x02 \x03(\x0c\"!\n\x11PublishBatchReply\x12\x0c\n\x04seqs\x18\x01 \x03(\x04\"f\n\nGetRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x14\n\x0cmax_messages\x18\x02 \x01(\r\x12\x15\n\x08lease_ms\x18\x03 \x01(\x04H\x00\x88\x01\x01\x12\x0f\n\x07wait_ms\x18\x04 \x01(\x04\x42\x0b\n\t_lease_ms\"Q\n\x08\x44\x65livery\x12\x0b\n\x03seq\x18\x01 \x01(\x04\x12\x12\n\ndeliveries\x18\x02 \x01(\r\x12\x16\n\x0e\x65nqueued_at_ms\x18\x03 \x01(\x04\x12\x0c\n\x04\x62ody\x18\x04 \x01(\x0c\"1\n\x08GetReply\x12%\n\x08messages\x18\x01 \x03(\x0b\x32\x13.leanqueue.Delivery\"*\n\x0bSeqsRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x0c\n\x04seqs\x18\x02 \x03(\x04\"8\n\x0bNackRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x0c\n\x04seqs\x18\x02 \x03(\x04\x12\x0c\n\x04\x64rop\x18\x03 \x01(\x08\"P\n\rExtendRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x0c\n\x04seqs\x18\x02 \x03(\x04\x12\x15\n\x08lease_ms\x18\x03 \x01(\x04H\x00\x88\x01\x01\x42\x0b\n\t_lease_ms\"\x1b\n\nCountReply\x12\r\n\x05\x63ount\x18\x01 \x01(\x04\"]\n\x0cMessageState\x12\x0e\n\x06\x65xists\x18\x01 \x01(\x08\x12\x11\n\tin_flight\x18\x02 \x01(\x08\x12\x12\n\ndeliveries\x18\x03 \x01(\r\x12\x16\n\x0elease_until_ms\x18\x04 \x01(\x04\"6\n\x0bStatesReply\x12\'\n\x06states\x18\x01 \x03(\x0b\x32\x17.leanqueue.MessageState\"n\n\x0e\x43onsumeRequest\x12\r\n\x05queue\x18\x01 \x01(\t\x12\x10\n\x08prefetch\x18\x02 \x01(\r\x12\x15\n\x08lease_ms\x18\x03 \x01(\x04H\x00\x88\x01\x01\x12\x17\n\x0fidle_timeout_ms\x18\x04 \x01(\x04\x42\x0b\n\t_lease_ms2\xe2\x06\n\tLeanQueue\x12:\n\x06Health\x12\x18.leanqueue.HealthRequest\x1a\x16.leanqueue.HealthReply\x12\x46\n\nListQueues\x12\x1c.leanqueue.ListQueuesRequest\x1a\x1a.leanqueue.ListQueuesReply\x12@\n\x0c\x44\x65\x63lareQueue\x12\x17.leanqueue.QueueRequest\x1a\x17.leanqueue.DeclareReply\x12>\n\x0b\x44\x65leteQueue\x12\x17.leanqueue.QueueRequest\x1a\x16.leanqueue.DeleteReply\x12\x37\n\x05Stats\x12\x17.leanqueue.QueueRequest\x1a\x15.leanqueue.StatsReply\x12=\n\x07Publish\x12\x19.leanqueue.PublishRequest\x1a\x17.leanqueue.PublishReply\x12L\n\x0cPublishBatch\x12\x1e.leanqueue.PublishBatchRequest\x1a\x1c.leanqueue.PublishBatchReply\x12\x31\n\x03Get\x12\x15.leanqueue.GetRequest\x1a\x13.leanqueue.GetReply\x12\x34\n\x03\x41\x63k\x12\x16.leanqueue.SeqsRequest\x1a\x15.leanqueue.CountReply\x12\x35\n\x04Nack\x12\x16.leanqueue.NackRequest\x1a\x15.leanqueue.CountReply\x12\x39\n\x06\x45xtend\x12\x18.leanqueue.ExtendRequest\x1a\x15.leanqueue.CountReply\x12\x38\n\x06States\x12\x16.leanqueue.SeqsRequest\x1a\x16.leanqueue.StatesReply\x12\x37\n\x05Purge\x12\x17.leanqueue.QueueRequest\x1a\x15.leanqueue.PurgeReply\x12;\n\x07\x43onsume\x12\x19.leanqueue.ConsumeRequest\x1a\x13.leanqueue.Delivery0\x01\x62\x06proto3')
|
|
28
|
+
|
|
29
|
+
_globals = globals()
|
|
30
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
31
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'leanqueue_pb2', _globals)
|
|
32
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
33
|
+
DESCRIPTOR._loaded_options = None
|
|
34
|
+
_globals['_HEALTHREQUEST']._serialized_start=30
|
|
35
|
+
_globals['_HEALTHREQUEST']._serialized_end=45
|
|
36
|
+
_globals['_HEALTHREPLY']._serialized_start=47
|
|
37
|
+
_globals['_HEALTHREPLY']._serialized_end=113
|
|
38
|
+
_globals['_LISTQUEUESREQUEST']._serialized_start=115
|
|
39
|
+
_globals['_LISTQUEUESREQUEST']._serialized_end=134
|
|
40
|
+
_globals['_LISTQUEUESREPLY']._serialized_start=136
|
|
41
|
+
_globals['_LISTQUEUESREPLY']._serialized_end=169
|
|
42
|
+
_globals['_QUEUEREQUEST']._serialized_start=171
|
|
43
|
+
_globals['_QUEUEREQUEST']._serialized_end=200
|
|
44
|
+
_globals['_DECLAREREPLY']._serialized_start=202
|
|
45
|
+
_globals['_DECLAREREPLY']._serialized_end=233
|
|
46
|
+
_globals['_DELETEREPLY']._serialized_start=235
|
|
47
|
+
_globals['_DELETEREPLY']._serialized_end=265
|
|
48
|
+
_globals['_STATSREPLY']._serialized_start=267
|
|
49
|
+
_globals['_STATSREPLY']._serialized_end=299
|
|
50
|
+
_globals['_PURGEREPLY']._serialized_start=301
|
|
51
|
+
_globals['_PURGEREPLY']._serialized_end=313
|
|
52
|
+
_globals['_PUBLISHREQUEST']._serialized_start=315
|
|
53
|
+
_globals['_PUBLISHREQUEST']._serialized_end=360
|
|
54
|
+
_globals['_PUBLISHREPLY']._serialized_start=362
|
|
55
|
+
_globals['_PUBLISHREPLY']._serialized_end=389
|
|
56
|
+
_globals['_PUBLISHBATCHREQUEST']._serialized_start=391
|
|
57
|
+
_globals['_PUBLISHBATCHREQUEST']._serialized_end=443
|
|
58
|
+
_globals['_PUBLISHBATCHREPLY']._serialized_start=445
|
|
59
|
+
_globals['_PUBLISHBATCHREPLY']._serialized_end=478
|
|
60
|
+
_globals['_GETREQUEST']._serialized_start=480
|
|
61
|
+
_globals['_GETREQUEST']._serialized_end=582
|
|
62
|
+
_globals['_DELIVERY']._serialized_start=584
|
|
63
|
+
_globals['_DELIVERY']._serialized_end=665
|
|
64
|
+
_globals['_GETREPLY']._serialized_start=667
|
|
65
|
+
_globals['_GETREPLY']._serialized_end=716
|
|
66
|
+
_globals['_SEQSREQUEST']._serialized_start=718
|
|
67
|
+
_globals['_SEQSREQUEST']._serialized_end=760
|
|
68
|
+
_globals['_NACKREQUEST']._serialized_start=762
|
|
69
|
+
_globals['_NACKREQUEST']._serialized_end=818
|
|
70
|
+
_globals['_EXTENDREQUEST']._serialized_start=820
|
|
71
|
+
_globals['_EXTENDREQUEST']._serialized_end=900
|
|
72
|
+
_globals['_COUNTREPLY']._serialized_start=902
|
|
73
|
+
_globals['_COUNTREPLY']._serialized_end=929
|
|
74
|
+
_globals['_MESSAGESTATE']._serialized_start=931
|
|
75
|
+
_globals['_MESSAGESTATE']._serialized_end=1024
|
|
76
|
+
_globals['_STATESREPLY']._serialized_start=1026
|
|
77
|
+
_globals['_STATESREPLY']._serialized_end=1080
|
|
78
|
+
_globals['_CONSUMEREQUEST']._serialized_start=1082
|
|
79
|
+
_globals['_CONSUMEREQUEST']._serialized_end=1192
|
|
80
|
+
_globals['_LEANQUEUE']._serialized_start=1195
|
|
81
|
+
_globals['_LEANQUEUE']._serialized_end=2061
|
|
82
|
+
# @@protoc_insertion_point(module_scope)
|