Skip to content

Commit

Permalink
Merge pull request #195 from shiguredo/feature/add-retry-condition
Browse files Browse the repository at this point in the history
リトライの条件にサーバからの切断を追加する
  • Loading branch information
Hexa authored Dec 24, 2024
2 parents 87f4ad8 + 9c47d49 commit 989b18d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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;") {
err = errors.Join(err, ErrServerDisconnected)
}
}

w.CloseWithError(err)
Expand Down

0 comments on commit 989b18d

Please sign in to comment.