[pg-query-stream] Allow 'destroy' option for QueryStream
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
調査の方向性
QueryStream の実装から始め、その Node.js ストリームスーパークラスを調べ、construct オプションと destroy オプションを super() に渡せるようにする方法に焦点を当てます。QueryStream がそれらのオプションを受け取り、転送できるようになり、追加の PassThrough オブジェクトなしで接続をクリーンアップできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Since I'm using QueryStream for a one-off task, I'd like to wrap it with a function that manages the connection for me.
export function streamAllRows(
config: ClientConfig,
query: string,
): stream.Readable;
However, client code needs to wait not just for the QueryStream to close, but also for the managed connection and client to be fully closed and ended.
My solution was to use the destroy argument to stream.PassThrough:
export async function streamAllRows(
config: ClientConfig,
query: string,
): Promise<stream.Readable> {
const client = new pg.Client(config);
await client.connect();
return client.query(new QueryStream(query))
.pipe(new stream.PassThrough({
objectMode: true,
destroy: (e: Error | null, callback) => {
void client.end().then(() => { callback(); }).catch(callback);
},
}));
}
This works well enough, but creates an extra object and seems unnecessarily circuitous. It would be more expressive to accept the construct and destroy arguments and forward them to super().
- 主要言語
- JavaScript
- スター
- 13.2k
- フォーク
- 1.4k
- 平均マージ
- 6日 15時間
- マージ済み PR(30日)
- 6
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
brianc/node-postgres のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
brianc/node-postgres#3770 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
brianc/node-postgres#3716 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
brianc/node-postgres#3631 · コメント 1 件 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 62/100
brianc/node-postgres#2857 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
brianc/node-postgres#2433 ·
brianc/node-postgres の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
antfu-collective/icones#398 ·
-
ECmail.com オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
wesbos/burner-email-providers#554 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
components-web-app/docs#92 ·