-
-
Save juliusv/551abc170c9c426e6180274add920bed to your computer and use it in GitHub Desktop.
Subscribe to all Bluesky firehose events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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