Skip to content

Instantly share code, notes, and snippets.

@juliusv

juliusv/main.go Secret

Created November 23, 2024 07:44
Show Gist options
  • Save juliusv/551abc170c9c426e6180274add920bed to your computer and use it in GitHub Desktop.
Save juliusv/551abc170c9c426e6180274add920bed to your computer and use it in GitHub Desktop.
Subscribe to all Bluesky firehose events
package main
import (
"context"
"fmt"
"net/http"
"github.com/bluesky-social/indigo/api/atproto"
"github.com/bluesky-social/indigo/events"
"github.com/bluesky-social/indigo/events/schedulers/sequential"
"github.com/gorilla/websocket"
)
func main() {
uri := "wss://bsky.network/xrpc/com.atproto.sync.subscribeRepos"
con, _, err := websocket.DefaultDialer.Dial(uri, http.Header{})
if err != nil {
panic(err)
}
rsc := &events.RepoStreamCallbacks{
RepoCommit: func(evt *atproto.SyncSubscribeRepos_Commit) error {
fmt.Println("Event from ", evt.Repo)
for _, op := range evt.Ops {
fmt.Printf(" - %s record %s\n", op.Action, op.Path)
}
return nil
},
}
sched := sequential.NewScheduler("myfirehose", rsc.EventHandler)
events.HandleRepoStream(context.Background(), con, sched)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment