Skip to content

Commit df83e77

Browse files
committed
create README for future readers
1 parent c6f1c82 commit df83e77

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# placedump
2+
3+
Toolset to make a best effort attempt to grab all r/place (2022) WebSocket messages, pixels, and canvases.
4+
5+
## Layout
6+
7+
Documenting layout which powered archival and parsing for the last 1.5 days of r/place.
8+
9+
### `dump.py`
10+
* Connects to Reddit's live servers and subscribes to all r/place canvas changes and config changes
11+
* Saves all messages to a Redis stream for later parsing
12+
* Pushes all messagesto a Redit PubSub channel
13+
14+
### `pixel_watcher.py`
15+
* Connects to Reddit's live servers to query pixel statuses in bulk to save on HTTP requests and data.
16+
* Fetches pixels in bulk from a Redis set `queue:pixels`
17+
* Spawns Celery task `pixels.update_pixel` for every pixel result from Reddit
18+
19+
### Celery
20+
* Main job queue for message processing
21+
* Redis used for job result storage and queuing
22+
23+
### Celery: Tasks
24+
* `parse.parse_message`
25+
- Parse GraphQL responses from the live WS
26+
- Canvas responses updated the current canvas ID
27+
- All pixel updates spawns a `pixels.download_url` task
28+
* `pixels.download_url`
29+
- Downloads URL passed into function
30+
- Uploads URL and result straight into Backblaze B2
31+
- Spawns `pixels.get_non_transparent` task
32+
- Adds URL into database
33+
* `pixels.update_pixel`
34+
- Postgres upsert insert for the Pixel table
35+
- Very inefficient but it did the job!
36+
- 192 processes were needed to handle the workload for this task
37+
- Certainly could have been improved with batching
38+
* `pixels.get_pixel`
39+
- Gets a single pixel from Reddit and calls `pixels.update_pixel`
40+
- Very inefficient
41+
- Guaranteed rate limit!
42+
* `pixels.get_non_transparent`
43+
- Thanks Stack Overflow. https://stackoverflow.com/questions/60051941/find-the-coordinates-in-an-image-where-a-specified-colour-is-detected
44+
- Parses a PNG passed as bytes over Celery and adds all pixels to Redis set `queue:pixels`
45+
- Returns all pixels as a list.
46+
47+
## dev runbook
48+
```
49+
# forever loop alias
50+
run_forever() { while :; do "$@"; sleep 1; done }
51+
52+
# deploy dump stack
53+
export DOCKER_HOST=unix:///tmp/docker.sock
54+
docker stack deploy -c docker-compose.yml --with-registry-auth placedump
55+
```

0 commit comments

Comments
 (0)