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

fix: Transformer による実装を変換処理のチェーンへと変更 #374

Merged
merged 6 commits into from
Aug 3, 2022

Conversation

MikuroXina
Copy link
Collaborator

Close #372.

Type of Change:

コードの修正

Cause of the Problem (問題の原因)

tuple.ts では, 反変関手の unzip 処理として (bs: [B1, B2]) => Promise<void>[(b1: B1) => Promise<void>, (b2: B2) => Promise<void>] へと変換する split 関数が存在していました. しかしこの実装では, 関数の引数を片方づつ受け取って溜め込み, 両方が揃ったら送り出すという実装になっていました. このために実行タイミングによっては正しく動作しない可能性があり, 再現性がないバグの原因となっていました.

Dealing with Problems (問題への対処)

そもそも反変関手の性質上 unzip 処理は不可能であるため, 根本的に複雑過ぎた変換処理を見直すことにしました. メッセージハンドラと同じ形の Promise を返すだけの関数を用いて, その関数が拒否された場合はメッセージの変換処理もといメッセージへの応答を中断する方針で実装することにしました.

Details of implementation (実施内容)

middleware.ts を追加し, メッセージ M をメッセージ N へ変換する処理 Middleware<M, N> を追加しました。これは単純な Promise チェーンによって結合され、これまでのボットのフィルタやコマンド向けの変換処理も同様に実装できます.

これによって, 「作成されたメッセージへの変換処理」を「更新されたメッセージへの変換処理」へと加工する liftTuple 関数も用意に実装できました. そのためこちらは middleware.ts 内へと移動しています.

@MikuroXina MikuroXina added the bug label Aug 3, 2022
@MikuroXina MikuroXina self-assigned this Aug 3, 2022
Copy link
Sponsor Member

@nanai10a nanai10a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

無責任reviewです

src/adaptor/proxy/message.ts Outdated Show resolved Hide resolved
Copy link
Sponsor Member

@nanai10a nanai10a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんかだいじょうぶそう (小並感)

Copy link
Contributor

@m1sk9 m1sk9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

無責任わからせapprove

@MikuroXina MikuroXina merged commit 0e19076 into main Aug 3, 2022
@MikuroXina MikuroXina deleted the fix/#372 branch August 3, 2022 11:27
@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2022

🎉 This PR is included in version 1.22.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: difference-detectorのdiffが正確でない
3 participants