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

リトライの条件にサーバからの切断を追加する #195

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
- @Hexa
- [CHANGE] フィルタリングの結果が句読点のみになった場合はクライアントに結果を返さないように変更する
- @Hexa
- [CHANGE] サーバから切断された場合はリトライするように変更する
- Amazon Transcribe のみ対象
- @Hexa

### misc

Expand Down
5 changes: 5 additions & 0 deletions amazon_transcribe_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"io"
"strings"
"sync"

"github.com/aws/aws-sdk-go/service/transcribestreamingservice"
Expand Down Expand Up @@ -187,6 +188,10 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, opusCh chan opusCh
*transcribestreamingservice.InternalFailureException:
err = errors.Join(err, ErrServerDisconnected)
default:
// サーバから切断された場合は再接続を試みる
if strings.Contains(err.Error(), "http2: server sent GOAWAY and closed the connection;") {
Hexa marked this conversation as resolved.
Show resolved Hide resolved
err = errors.Join(err, ErrServerDisconnected)
}
}

w.CloseWithError(err)
Expand Down