tasklease 0.1.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.
Files changed (48) hide show
  1. tasklease/__init__.py +7 -0
  2. tasklease/__main__.py +5 -0
  3. tasklease/cli/__init__.py +53 -0
  4. tasklease/cli/common.py +87 -0
  5. tasklease/cli/identity.py +106 -0
  6. tasklease/cli/inbox.py +37 -0
  7. tasklease/cli/monitor.py +57 -0
  8. tasklease/cli/requester.py +197 -0
  9. tasklease/cli/service.py +169 -0
  10. tasklease/cli/tasks.py +175 -0
  11. tasklease/cli/topics.py +65 -0
  12. tasklease/cli/worker.py +186 -0
  13. tasklease/client.py +283 -0
  14. tasklease/cloudflare/__init__.py +6 -0
  15. tasklease/cloudflare/bundle.py +78 -0
  16. tasklease/cloudflare/deployer.py +714 -0
  17. tasklease/cloudflare/wrangler.py +300 -0
  18. tasklease/config.py +206 -0
  19. tasklease/errors.py +89 -0
  20. tasklease/fsio.py +275 -0
  21. tasklease/generated/__init__.py +1 -0
  22. tasklease/generated/protocol.py +478 -0
  23. tasklease/monitor/__init__.py +1 -0
  24. tasklease/monitor/server.py +325 -0
  25. tasklease/monitor/static/THIRD_PARTY_NOTICES.md +25 -0
  26. tasklease/monitor/static/assets/index-ClHk7fvq.css +1 -0
  27. tasklease/monitor/static/assets/index-CmFr3mRG.js +6 -0
  28. tasklease/monitor/static/index.html +13 -0
  29. tasklease/names.py +60 -0
  30. tasklease/py.typed +0 -0
  31. tasklease/service_bundle/README.md +1 -0
  32. tasklease/service_bundle/THIRD_PARTY_NOTICES.md +2163 -0
  33. tasklease/service_bundle/index.js +18533 -0
  34. tasklease/service_bundle/index.js.map +8 -0
  35. tasklease/service_bundle/manifest.json +4 -0
  36. tasklease/service_bundle/wrangler.template.jsonc +53 -0
  37. tasklease/store.py +669 -0
  38. tasklease/worker.py +444 -0
  39. tasklease/worker_control.py +114 -0
  40. tasklease/worker_templates/launchd.plist +22 -0
  41. tasklease/worker_templates/systemd.service +15 -0
  42. tasklease/worker_templates/windows-stop.ps1 +4 -0
  43. tasklease/worker_templates/windows.xml +27 -0
  44. tasklease-0.1.0.dist-info/METADATA +495 -0
  45. tasklease-0.1.0.dist-info/RECORD +48 -0
  46. tasklease-0.1.0.dist-info/WHEEL +4 -0
  47. tasklease-0.1.0.dist-info/entry_points.txt +2 -0
  48. tasklease-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,478 @@
1
+ # Generated by scripts/codegen.mjs. Do not edit.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, NotRequired, TypedDict
6
+
7
+
8
+ type DomainName = str
9
+
10
+
11
+ type TopicName1 = str
12
+
13
+
14
+ type TopicName = TopicName1
15
+
16
+
17
+ type TopicGlob = str
18
+
19
+
20
+ type TaskId = str
21
+
22
+
23
+ type Timestamp = int
24
+
25
+
26
+ type WorkerLabel = str
27
+
28
+
29
+ type IdentityName = str
30
+
31
+
32
+ type ErrorCode = Literal[
33
+ "invalid",
34
+ "unauthenticated",
35
+ "forbidden",
36
+ "not_found",
37
+ "empty",
38
+ "exists",
39
+ "too_large",
40
+ ]
41
+
42
+
43
+ class Error(TypedDict):
44
+ code: ErrorCode
45
+ message: str
46
+
47
+
48
+ class ErrorResponse(TypedDict):
49
+ ok: Literal[False]
50
+ error: Error
51
+
52
+
53
+ class Owner(TypedDict):
54
+ identity: IdentityName
55
+ worker: WorkerLabel
56
+
57
+
58
+ class Scopes(TypedDict):
59
+ create: list[TopicGlob]
60
+ own: list[TopicGlob]
61
+ read: list[TopicGlob]
62
+
63
+
64
+ class Identity(TypedDict):
65
+ name: IdentityName
66
+ domains: list[DomainName]
67
+ scopes: Scopes
68
+ operator: bool
69
+
70
+
71
+ class IdentitySummary(TypedDict):
72
+ name: IdentityName
73
+ domains: list[DomainName]
74
+ scopes: Scopes
75
+ operator: bool
76
+ created_at: Timestamp
77
+ last_seen_at: Timestamp | None
78
+
79
+
80
+ class Poller(TypedDict):
81
+ identity: IdentityName
82
+ worker: WorkerLabel
83
+ last_polled_at: Timestamp
84
+ last_owned_at: Timestamp | None
85
+
86
+
87
+ class TopicSummary(TypedDict):
88
+ topic: TopicName
89
+ available: int
90
+ held: int
91
+ oldest_available_at: Timestamp | None
92
+ declared: bool
93
+
94
+
95
+ class TaskSummary(TypedDict):
96
+ id: TaskId
97
+ created_at: Timestamp
98
+ lease_until: Timestamp
99
+ owned_count: int
100
+ creator: IdentityName
101
+ owner: Owner | None
102
+ owned_at: Timestamp | None
103
+ state: Literal["available", "held"]
104
+
105
+
106
+ class SnapshotTopic(TypedDict):
107
+ topic: TopicName
108
+ available: int
109
+ held: int
110
+ oldest_available_at: Timestamp | None
111
+ declared: bool
112
+ pollers: list[Poller]
113
+ tasks: list[TaskSummary]
114
+ truncated: NotRequired[Literal[True]]
115
+
116
+
117
+ class HourlyStats(TypedDict):
118
+ topic: TopicName
119
+ hour: Timestamp
120
+ created: int
121
+ owned: int
122
+ reowned: int
123
+ consumed: int
124
+ deleted: int
125
+ wait_ms_sum: int
126
+ wait_ms_max: int
127
+ wait_count: int
128
+ run_ms_sum: int
129
+ run_ms_max: int
130
+ run_count: int
131
+
132
+
133
+ class BlobGetUrlRequest(TypedDict):
134
+ domain: DomainName
135
+ key: str
136
+
137
+
138
+ class BlobGetUrlResponse(TypedDict):
139
+ ok: Literal[True]
140
+ url: str
141
+ expires_at: Timestamp
142
+
143
+
144
+ class BlobPutUrlRequest(TypedDict):
145
+ domain: DomainName
146
+ name: str
147
+ size: int
148
+ sha256: str
149
+
150
+
151
+ class BlobPutUrlResponse(TypedDict):
152
+ ok: Literal[True]
153
+ key: str
154
+ url: str
155
+ expires_at: Timestamp
156
+
157
+
158
+ class ConsumeResponse(TypedDict):
159
+ ok: Literal[True]
160
+ ids: list[TaskId]
161
+
162
+
163
+ class CreateResponse(TypedDict):
164
+ ok: Literal[True]
165
+ id: TaskId
166
+
167
+
168
+ class DeleteRequest(TypedDict):
169
+ domain: DomainName
170
+ topic: TopicName
171
+ id: TaskId
172
+ lease_before: NotRequired[Timestamp]
173
+
174
+
175
+ class DeleteResponse(TypedDict):
176
+ ok: Literal[True]
177
+
178
+
179
+ class IdentityAddRequest(TypedDict):
180
+ name: IdentityName
181
+ domains: list[DomainName]
182
+ scopes: Scopes
183
+ operator: bool
184
+
185
+
186
+ class IdentityAddResponse(TypedDict):
187
+ ok: Literal[True]
188
+ name: IdentityName
189
+ token: str
190
+
191
+
192
+ class IdentityListRequest(TypedDict):
193
+ pass
194
+
195
+
196
+ class IdentityListResponse(TypedDict):
197
+ ok: Literal[True]
198
+ identities: list[IdentitySummary]
199
+
200
+
201
+ class IdentityRevokeRequest(TypedDict):
202
+ name: IdentityName
203
+
204
+
205
+ class IdentityRevokeResponse(TypedDict):
206
+ ok: Literal[True]
207
+
208
+
209
+ class IdentityRotateRequest(TypedDict):
210
+ name: IdentityName
211
+
212
+
213
+ class IdentityRotateResponse(TypedDict):
214
+ ok: Literal[True]
215
+ token: str
216
+
217
+
218
+ class IdentityWhoamiRequest(TypedDict):
219
+ pass
220
+
221
+
222
+ class IdentityWhoamiResponse(TypedDict):
223
+ ok: Literal[True]
224
+ name: IdentityName
225
+ domains: list[DomainName]
226
+ scopes: Scopes
227
+ operator: bool
228
+
229
+
230
+ class MonitorSnapshotRequest(TypedDict):
231
+ domain: DomainName
232
+ hours: NotRequired[int]
233
+
234
+
235
+ class MonitorSnapshotResponse(TypedDict):
236
+ ok: Literal[True]
237
+ domain: DomainName
238
+ generated_at: Timestamp
239
+ topics: list[SnapshotTopic]
240
+ stats: list[HourlyStats]
241
+
242
+
243
+ class OwnRequest(TypedDict):
244
+ domain: DomainName
245
+ topic: TopicName
246
+ hold_seconds: int
247
+
248
+
249
+ class ReadRequest(TypedDict):
250
+ domain: DomainName
251
+ topic: TopicName
252
+ id: TaskId
253
+
254
+
255
+ class RenewRequest(TypedDict):
256
+ domain: DomainName
257
+ topic: TopicName
258
+ id: TaskId
259
+ hold_seconds: int
260
+
261
+
262
+ class TasksListRequest(TypedDict):
263
+ domain: DomainName
264
+ topic: TopicName
265
+ cursor: NotRequired[str]
266
+
267
+
268
+ class TasksListResponse(TypedDict):
269
+ ok: Literal[True]
270
+ tasks: list[TaskSummary]
271
+ cursor: NotRequired[str]
272
+
273
+
274
+ class TopicDeclareRequest(TypedDict):
275
+ domain: DomainName
276
+ topic: TopicName
277
+ declared: bool
278
+
279
+
280
+ class TopicDeclareResponse(TypedDict):
281
+ ok: Literal[True]
282
+
283
+
284
+ class TopicPollersRequest(TypedDict):
285
+ domain: DomainName
286
+ topic: TopicName
287
+
288
+
289
+ class TopicPollersResponse(TypedDict):
290
+ ok: Literal[True]
291
+ pollers: list[Poller]
292
+
293
+
294
+ class TopicsListRequest(TypedDict):
295
+ domain: DomainName
296
+ glob: NotRequired[TopicGlob]
297
+
298
+
299
+ class TopicsListResponse(TypedDict):
300
+ ok: Literal[True]
301
+ topics: list[TopicSummary]
302
+
303
+
304
+ class VersionRequest(TypedDict):
305
+ pass
306
+
307
+
308
+ class VersionResponse(TypedDict):
309
+ service_version: str
310
+ protocol: Literal["v1"]
311
+
312
+
313
+ class ProtocolTypes(TypedDict):
314
+ DomainName: NotRequired[DomainName]
315
+ TopicName: NotRequired[TopicName]
316
+ TopicGlob: NotRequired[TopicGlob]
317
+ TaskId: NotRequired[TaskId]
318
+ Timestamp: NotRequired[Timestamp]
319
+ WorkerLabel: NotRequired[WorkerLabel]
320
+ IdentityName: NotRequired[IdentityName]
321
+ Data: NotRequired[Data]
322
+ ErrorCode: NotRequired[ErrorCode]
323
+ Error: NotRequired[Error]
324
+ ErrorResponse: NotRequired[ErrorResponse]
325
+ Owner: NotRequired[Owner]
326
+ Scopes: NotRequired[Scopes]
327
+ Identity: NotRequired[Identity]
328
+ IdentitySummary: NotRequired[IdentitySummary]
329
+ NewTask: NotRequired[NewTask]
330
+ Poller: NotRequired[Poller]
331
+ TopicSummary: NotRequired[TopicSummary]
332
+ Task: NotRequired[Task]
333
+ TaskSummary: NotRequired[TaskSummary]
334
+ SnapshotTopic: NotRequired[SnapshotTopic]
335
+ HourlyStats: NotRequired[HourlyStats]
336
+ JsonValue: NotRequired[JsonValue]
337
+ BlobGetUrlRequest: NotRequired[BlobGetUrlRequest]
338
+ BlobGetUrlResponse: NotRequired[BlobGetUrlResponse]
339
+ BlobPutUrlRequest: NotRequired[BlobPutUrlRequest]
340
+ BlobPutUrlResponse: NotRequired[BlobPutUrlResponse]
341
+ ConsumeRequest: NotRequired[ConsumeRequest]
342
+ ConsumeResponse: NotRequired[ConsumeResponse]
343
+ CreateRequest: NotRequired[CreateRequest]
344
+ CreateResponse: NotRequired[CreateResponse]
345
+ DeleteRequest: NotRequired[DeleteRequest]
346
+ DeleteResponse: NotRequired[DeleteResponse]
347
+ IdentityAddRequest: NotRequired[IdentityAddRequest]
348
+ IdentityAddResponse: NotRequired[IdentityAddResponse]
349
+ IdentityListRequest: NotRequired[IdentityListRequest]
350
+ IdentityListResponse: NotRequired[IdentityListResponse]
351
+ IdentityRevokeRequest: NotRequired[IdentityRevokeRequest]
352
+ IdentityRevokeResponse: NotRequired[IdentityRevokeResponse]
353
+ IdentityRotateRequest: NotRequired[IdentityRotateRequest]
354
+ IdentityRotateResponse: NotRequired[IdentityRotateResponse]
355
+ IdentityWhoamiRequest: NotRequired[IdentityWhoamiRequest]
356
+ IdentityWhoamiResponse: NotRequired[IdentityWhoamiResponse]
357
+ MonitorSnapshotRequest: NotRequired[MonitorSnapshotRequest]
358
+ MonitorSnapshotResponse: NotRequired[MonitorSnapshotResponse]
359
+ OwnRequest: NotRequired[OwnRequest]
360
+ OwnResponse: NotRequired[OwnResponse]
361
+ ReadRequest: NotRequired[ReadRequest]
362
+ ReadResponse: NotRequired[ReadResponse]
363
+ RenewRequest: NotRequired[RenewRequest]
364
+ RenewResponse: NotRequired[RenewResponse]
365
+ TasksListRequest: NotRequired[TasksListRequest]
366
+ TasksListResponse: NotRequired[TasksListResponse]
367
+ TopicDeclareRequest: NotRequired[TopicDeclareRequest]
368
+ TopicDeclareResponse: NotRequired[TopicDeclareResponse]
369
+ TopicPollersRequest: NotRequired[TopicPollersRequest]
370
+ TopicPollersResponse: NotRequired[TopicPollersResponse]
371
+ TopicsListRequest: NotRequired[TopicsListRequest]
372
+ TopicsListResponse: NotRequired[TopicsListResponse]
373
+ VersionRequest: NotRequired[VersionRequest]
374
+ VersionResponse: NotRequired[VersionResponse]
375
+ OperationRequests: NotRequired[OperationRequests]
376
+ OperationResponses: NotRequired[OperationResponses]
377
+
378
+
379
+ type Data = dict[str, JsonValue]
380
+
381
+
382
+ class NewTask(TypedDict):
383
+ topic: TopicName
384
+ data: Data
385
+
386
+
387
+ class Task(TypedDict):
388
+ id: TaskId
389
+ domain: DomainName
390
+ topic: TopicName
391
+ created_at: Timestamp
392
+ lease_until: Timestamp
393
+ owned_count: int
394
+ creator: IdentityName
395
+ owner: Owner | None
396
+ owned_at: Timestamp | None
397
+ data: Data
398
+
399
+
400
+ type JsonValue = bool | float | str | list[JsonValue] | Data | None
401
+
402
+
403
+ class ConsumeRequest(TypedDict):
404
+ domain: DomainName
405
+ topic: TopicName
406
+ id: TaskId
407
+ tasks: list[NewTask]
408
+
409
+
410
+ class CreateRequest(TypedDict):
411
+ domain: DomainName
412
+ topic: TopicName
413
+ data: Data
414
+
415
+
416
+ class OwnResponse(TypedDict):
417
+ ok: Literal[True]
418
+ task: Task
419
+
420
+
421
+ class ReadResponse(TypedDict):
422
+ ok: Literal[True]
423
+ task: Task
424
+
425
+
426
+ class RenewResponse(TypedDict):
427
+ ok: Literal[True]
428
+ task: Task
429
+
430
+
431
+ OperationRequests = TypedDict(
432
+ "OperationRequests",
433
+ {
434
+ "blob.get_url": BlobGetUrlRequest,
435
+ "blob.put_url": BlobPutUrlRequest,
436
+ "consume": ConsumeRequest,
437
+ "create": CreateRequest,
438
+ "delete": DeleteRequest,
439
+ "identity.add": IdentityAddRequest,
440
+ "identity.list": IdentityListRequest,
441
+ "identity.revoke": IdentityRevokeRequest,
442
+ "identity.rotate": IdentityRotateRequest,
443
+ "identity.whoami": IdentityWhoamiRequest,
444
+ "monitor.snapshot": MonitorSnapshotRequest,
445
+ "own": OwnRequest,
446
+ "read": ReadRequest,
447
+ "renew": RenewRequest,
448
+ "tasks.list": TasksListRequest,
449
+ "topic.declare": TopicDeclareRequest,
450
+ "topic.pollers": TopicPollersRequest,
451
+ "topics.list": TopicsListRequest,
452
+ },
453
+ )
454
+
455
+
456
+ OperationResponses = TypedDict(
457
+ "OperationResponses",
458
+ {
459
+ "blob.get_url": BlobGetUrlResponse,
460
+ "blob.put_url": BlobPutUrlResponse,
461
+ "consume": ConsumeResponse,
462
+ "create": CreateResponse,
463
+ "delete": DeleteResponse,
464
+ "identity.add": IdentityAddResponse,
465
+ "identity.list": IdentityListResponse,
466
+ "identity.revoke": IdentityRevokeResponse,
467
+ "identity.rotate": IdentityRotateResponse,
468
+ "identity.whoami": IdentityWhoamiResponse,
469
+ "monitor.snapshot": MonitorSnapshotResponse,
470
+ "own": OwnResponse,
471
+ "read": ReadResponse,
472
+ "renew": RenewResponse,
473
+ "tasks.list": TasksListResponse,
474
+ "topic.declare": TopicDeclareResponse,
475
+ "topic.pollers": TopicPollersResponse,
476
+ "topics.list": TopicsListResponse,
477
+ },
478
+ )
@@ -0,0 +1 @@
1
+ """Read-only local access to remote snapshots and durable requester state."""