Skip to content

Commit

Permalink
サービスへの接続が成功した時点でリトライ回数をリセットする
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexa committed Nov 22, 2024
1 parent b8a17ec commit da9251a
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 4 additions & 0 deletions amazon_transcribe_handler.go
Original file line number Diff line number Diff line change
@@ -120,6 +120,9 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, reader io.Reader)
return nil, err
}

// リクエストが成功した時点でリトライカウントをリセットする
h.ResetRetryCount()

r, w := io.Pipe()

go func() {
@@ -195,6 +198,7 @@ func (h *AmazonTranscribeHandler) Handle(ctx context.Context, reader io.Reader)
switch err.(type) {
case *transcribestreamingservice.LimitExceededException,
*transcribestreamingservice.InternalFailureException:
// TODO: 元の err を送信する
err = ErrServerDisconnected
default:
}
8 changes: 0 additions & 8 deletions handler.go
Original file line number Diff line number Diff line change
@@ -223,14 +223,6 @@ func (s *Server) createSpeechHandler(serviceType string, onResultFunc func(conte
return err
}

// 1 度でも接続結果を受け取れた場合はリトライ回数をリセットする
serviceHandler.ResetRetryCount()
zlog.Debug().
Str("channel_id", h.SoraChannelID).
Str("connection_id", h.SoraConnectionID).
Int("retry_count", serviceHandler.GetRetryCount()).
Msg("RESET_RETRY_COUNT")

// メッセージが空でない場合はクライアントに結果を送信する
if n > 0 {
if _, err := c.Response().Write(buf[:n]); err != nil {
2 changes: 2 additions & 0 deletions speech_to_text_handler.go
Original file line number Diff line number Diff line change
@@ -115,6 +115,8 @@ func (h *SpeechToTextHandler) Handle(ctx context.Context, reader io.Reader) (*io
return nil, err
}

h.ResetRetryCount()

r, w := io.Pipe()

go func() {

0 comments on commit da9251a

Please sign in to comment.