Skip to content

Commit

Permalink
Sync: pass through websocket opts (bluesky-social#2992)
Browse files Browse the repository at this point in the history
* pass through websocket options in firehose

* changeset

* import type
  • Loading branch information
dholms authored Dec 6, 2024
1 parent c9848ed commit 0bec389
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 83 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-clouds-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/sync": patch
---

Pass through options to websocket
3 changes: 2 additions & 1 deletion packages/sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"@atproto/syntax": "workspace:^",
"@atproto/xrpc-server": "workspace:^",
"multiformats": "^9.9.0",
"p-queue": "^6.6.2"
"p-queue": "^6.6.2",
"ws": "^8.12.0"
},
"devDependencies": {
"jest": "^28.1.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/sync/src/firehose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '@atproto/repo'
import { AtUri } from '@atproto/syntax'
import { Subscription } from '@atproto/xrpc-server'
import type { ClientOptions } from 'ws'
import {
type Account,
type Commit,
Expand All @@ -37,7 +38,7 @@ import { CID } from 'multiformats/cid'
import { EventRunner } from '../runner'
import { didAndSeqForEvt } from '../util'

export type FirehoseOptions = {
export type FirehoseOptions = ClientOptions & {
idResolver: IdResolver

handleEvent: (evt: Event) => Awaited<void>
Expand Down Expand Up @@ -70,6 +71,7 @@ export class Firehose {
throw new Error('Must set only `getCursor` or `runner`')
}
this.sub = new Subscription({
...opts,
service: opts.service ?? 'wss://bsky.network',
method: 'com.atproto.sync.subscribeRepos',
signal: this.abortController.signal,
Expand Down
103 changes: 22 additions & 81 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0bec389

Please sign in to comment.