Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support http2 client for appview dataplane #1992

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions packages/bsky/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface ServerConfigValues {
serverDid: string
feedGenDid?: string
dataplaneUrl: string
dataplaneHttpVersion?: '1.1' | '2'
dataplaneIgnoreBadTls?: boolean
didPlcUrl: string
handleResolveNameservers?: string[]
imgUriEndpoint?: string
Expand Down Expand Up @@ -36,10 +38,14 @@ export class ServerConfig {
const imgUriEndpoint = process.env.BSKY_IMG_URI_ENDPOINT
const blobCacheLocation = process.env.BSKY_BLOB_CACHE_LOC
const dataplaneUrl = process.env.BSKY_DATAPLANE_URL
const dataplaneHttpVersion = process.env.BSKY_DATAPLANE_HTTP_VERSION || '2'
const dataplaneIgnoreBadTls =
process.env.BSKY_DATAPLANE_IGNORE_BAD_TLS === 'true'
const adminPassword = process.env.BSKY_ADMIN_PASSWORD || 'admin'
const moderatorPassword = process.env.BSKY_MODERATOR_PASSWORD || undefined
const triagePassword = process.env.BSKY_TRIAGE_PASSWORD || undefined
assert(dataplaneUrl)
assert(dataplaneHttpVersion === '1.1' || dataplaneHttpVersion === '2')
return new ServerConfig({
version,
debugMode,
Expand All @@ -48,6 +54,8 @@ export class ServerConfig {
serverDid,
feedGenDid,
dataplaneUrl,
dataplaneHttpVersion,
dataplaneIgnoreBadTls,
didPlcUrl,
handleResolveNameservers,
imgUriEndpoint,
Expand Down Expand Up @@ -100,6 +108,14 @@ export class ServerConfig {
return this.cfg.dataplaneUrl
}

get dataplaneHttpVersion() {
return this.cfg.dataplaneHttpVersion
}

get dataplaneIgnoreBadTls() {
return this.cfg.dataplaneIgnoreBadTls
}

get handleResolveNameservers() {
return this.cfg.handleResolveNameservers
}
Expand Down
4 changes: 3 additions & 1 deletion packages/bsky/src/data-plane/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ type HttpVersion = '1.1' | '2'

export const createDataPlaneClient = (
baseUrl: string,
httpVersion: HttpVersion = '2',
opts: { httpVersion?: HttpVersion; rejectUnauthorized?: boolean },
) => {
const { httpVersion = '2', rejectUnauthorized = false } = opts
const transport = createConnectTransport({
baseUrl,
httpVersion,
nodeOptions: { rejectUnauthorized },
})
return createPromiseClient(Service, transport)
}
5 changes: 4 additions & 1 deletion packages/bsky/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ export class BskyAppView {
)
}

const dataplane = createDataPlaneClient(config.dataplaneUrl, '1.1')
const dataplane = createDataPlaneClient(config.dataplaneUrl, {
httpVersion: config.dataplaneHttpVersion,
rejectUnauthorized: config.dataplaneIgnoreBadTls,
})
const hydrator = new Hydrator(dataplane)
const views = new Views(imgUriBuilder)

Expand Down
1 change: 1 addition & 0 deletions packages/dev-env/src/bsky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class TestBsky {
publicUrl: 'https://bsky.public.url',
serverDid,
dataplaneUrl: `http://localhost:${dataplanePort}`,
dataplaneHttpVersion: '1.1',
...cfg,
adminPassword: ADMIN_PASSWORD,
moderatorPassword: MOD_PASSWORD,
Expand Down
Loading