datasette-events-forward 0.1a0__py3-none-any.whl → 0.1a2__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.
Potentially problematic release.
This version of datasette-events-forward might be problematic. Click here for more details.
- datasette_events_forward/__init__.py +15 -7
- {datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info}/METADATA +9 -7
- datasette_events_forward-0.1a2.dist-info/RECORD +7 -0
- {datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info}/WHEEL +1 -1
- datasette_events_forward-0.1a0.dist-info/RECORD +0 -7
- {datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info}/entry_points.txt +0 -0
- {datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info/licenses}/LICENSE +0 -0
- {datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info}/top_level.txt +0 -0
|
@@ -17,7 +17,6 @@ create table if not exists datasette_events_to_forward (
|
|
|
17
17
|
database_name text,
|
|
18
18
|
table_name text,
|
|
19
19
|
properties text, -- JSON other properties
|
|
20
|
-
sent_at text,
|
|
21
20
|
failures integer default 0
|
|
22
21
|
)
|
|
23
22
|
"""
|
|
@@ -25,6 +24,9 @@ create table if not exists datasette_events_to_forward (
|
|
|
25
24
|
# Default is to allow 1 every 10s
|
|
26
25
|
rate_limit = AsyncLimiter(max_rate=1, time_period=10)
|
|
27
26
|
|
|
27
|
+
# Lock to prevent concurrent send_events() calls
|
|
28
|
+
send_events_lock = asyncio.Lock()
|
|
29
|
+
|
|
28
30
|
DEFAULT_BATCH_LIMIT = 10
|
|
29
31
|
|
|
30
32
|
|
|
@@ -43,7 +45,7 @@ async def send_events(datasette):
|
|
|
43
45
|
await db.execute(
|
|
44
46
|
"""
|
|
45
47
|
select * from datasette_events_to_forward
|
|
46
|
-
where
|
|
48
|
+
where failures < 3
|
|
47
49
|
order by id limit {}""".format(
|
|
48
50
|
batch_limit + 1
|
|
49
51
|
)
|
|
@@ -92,14 +94,14 @@ async def send_events(datasette):
|
|
|
92
94
|
headers={"Authorization": "Bearer {}".format(api_token)},
|
|
93
95
|
)
|
|
94
96
|
if str(response.status_code).startswith("2"):
|
|
95
|
-
# It worked! Mark the rows as sent
|
|
97
|
+
# It worked! Mark the rows as sent by deleting them
|
|
96
98
|
await db.execute_write(
|
|
97
99
|
"""
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
delete from datasette_events_to_forward
|
|
101
|
+
where id in ({})""".format(
|
|
100
102
|
",".join(["?"] * len(rows))
|
|
101
103
|
),
|
|
102
|
-
[
|
|
104
|
+
[row["id"] for row in rows],
|
|
103
105
|
)
|
|
104
106
|
else:
|
|
105
107
|
# Schedule a retry task
|
|
@@ -119,6 +121,7 @@ async def send_events(datasette):
|
|
|
119
121
|
[row["id"] for row in rows],
|
|
120
122
|
)
|
|
121
123
|
should_run_again = True
|
|
124
|
+
|
|
122
125
|
if should_run_again:
|
|
123
126
|
asyncio.create_task(rate_limited_send_events(datasette))
|
|
124
127
|
|
|
@@ -128,7 +131,8 @@ async def rate_limited_send_events(datasette):
|
|
|
128
131
|
# had been inserted before the send_events() function was called
|
|
129
132
|
await asyncio.sleep(0.05)
|
|
130
133
|
async with rate_limit:
|
|
131
|
-
|
|
134
|
+
async with send_events_lock:
|
|
135
|
+
await send_events(datasette)
|
|
132
136
|
|
|
133
137
|
|
|
134
138
|
@hookimpl
|
|
@@ -149,6 +153,10 @@ def startup(datasette):
|
|
|
149
153
|
|
|
150
154
|
@hookimpl
|
|
151
155
|
def track_event(datasette, event):
|
|
156
|
+
config = datasette.plugin_config("datasette-events-forward") or {}
|
|
157
|
+
if not config.get("api_url"):
|
|
158
|
+
return
|
|
159
|
+
|
|
152
160
|
async def inner():
|
|
153
161
|
db = datasette.get_internal_database()
|
|
154
162
|
properties = event.properties()
|
{datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: datasette-events-forward
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1a2
|
|
4
4
|
Summary: Forward Datasette events to another instance
|
|
5
5
|
Author: Simon Willison
|
|
6
6
|
License: Apache-2.0
|
|
@@ -13,14 +13,16 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
13
13
|
Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: datasette
|
|
16
|
+
Requires-Dist: datasette==1.0a19
|
|
17
17
|
Requires-Dist: python-ulid
|
|
18
18
|
Requires-Dist: aiolimiter
|
|
19
|
+
Requires-Dist: typing_extensions
|
|
19
20
|
Provides-Extra: test
|
|
20
|
-
Requires-Dist: pytest
|
|
21
|
-
Requires-Dist: pytest-asyncio
|
|
22
|
-
Requires-Dist: pytest-httpx
|
|
23
|
-
Requires-Dist: datasette-test
|
|
21
|
+
Requires-Dist: pytest; extra == "test"
|
|
22
|
+
Requires-Dist: pytest-asyncio; extra == "test"
|
|
23
|
+
Requires-Dist: pytest-httpx; extra == "test"
|
|
24
|
+
Requires-Dist: datasette-test; extra == "test"
|
|
25
|
+
Dynamic: license-file
|
|
24
26
|
|
|
25
27
|
# datasette-events-forward
|
|
26
28
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
datasette_events_forward/__init__.py,sha256=abRlM75YQwG8cjOMdR0TaR3GTtt_hZTfobVeKRp2T58,6233
|
|
2
|
+
datasette_events_forward-0.1a2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
3
|
+
datasette_events_forward-0.1a2.dist-info/METADATA,sha256=J0acEBm0ZeKmfBPBXkmYg-3aGKRR7Vmprtq4-gI4wRM,4215
|
|
4
|
+
datasette_events_forward-0.1a2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
+
datasette_events_forward-0.1a2.dist-info/entry_points.txt,sha256=gA9e336VTQukKzZ31P5fcujufJVRjNCqbOrQco5xQ-Q,54
|
|
6
|
+
datasette_events_forward-0.1a2.dist-info/top_level.txt,sha256=hcEFDCsbPWOqo39qf1PpGpWEqFsGk6wrZOTbR24TYqM,25
|
|
7
|
+
datasette_events_forward-0.1a2.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
datasette_events_forward/__init__.py,sha256=UrZq2LbwZAGeJ3Ft93rs5HJK3ATgcgWc5Y346c8NZvc,6061
|
|
2
|
-
datasette_events_forward-0.1a0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
3
|
-
datasette_events_forward-0.1a0.dist-info/METADATA,sha256=R6sNYUnPSSLPswLMjfk5GIwIfONZbVAeX8XEnz53TlY,4165
|
|
4
|
-
datasette_events_forward-0.1a0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
5
|
-
datasette_events_forward-0.1a0.dist-info/entry_points.txt,sha256=gA9e336VTQukKzZ31P5fcujufJVRjNCqbOrQco5xQ-Q,54
|
|
6
|
-
datasette_events_forward-0.1a0.dist-info/top_level.txt,sha256=hcEFDCsbPWOqo39qf1PpGpWEqFsGk6wrZOTbR24TYqM,25
|
|
7
|
-
datasette_events_forward-0.1a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{datasette_events_forward-0.1a0.dist-info → datasette_events_forward-0.1a2.dist-info}/top_level.txt
RENAMED
|
File without changes
|