Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions 18-wasmsockets-stream-consumer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Wasmsockets Stream Consumer - Bluesky Firehose

This example demonstrates a long-running Durable Object that connects to the Bluesky firehose (via Jetstream) and filters for post events, with rate limiting to print at most 1 per second.

This is the same as 14-websocket-stream-consumer, but it uses the wasmsockets package for WebSocket connections.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should update that example instead of adding a new one (the names are pretty similar as well).


## How to Run

First ensure that `uv` is installed:
https://docs.astral.sh/uv/getting-started/installation/#standalone-installer

Now, if you run `uv run pywrangler dev` within this directory, it should use the config
in `wrangler.jsonc` to run the example.

You can also run `uv run pywrangler deploy` to deploy the example.

## Testing the Firehose Consumer

1. Start the worker: `uv run pywrangler dev`
2. Make any request to initialize the DO: `curl "http://localhost:8787/status"`
3. Watch the logs to see filtered Bluesky post events in real-time (rate limited to 1/sec)!

The Durable Object automatically connects to Jetstream when first accessed. It will maintain a persistent WebSocket connection and print out post events to the console, including the author DID, post text (truncated to 100 chars), and timestamp. Posts are rate limited to display at most 1 per second to avoid overwhelming the logs.

**Available endpoints:**
- `/status` - Check connection status
- `/reconnect` - Manually trigger reconnection if disconnected
Loading
Loading