Skip to content

Commit

Permalink
fix: handle async call not being able to be called
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Jun 5, 2024
1 parent 18c2058 commit ff51164
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1219,19 +1219,21 @@ func (s *Service) executeAsyncCalls(ctx context.Context) (time.Duration, error)
Body: call.Request,
}
resp, err := s.callWithRequest(ctx, connect.NewRequest(req), optional.None[model.RequestKey](), s.config.Advertise.String())
if err != nil {
return 0, fmt.Errorf("async call failed: %w", err)
}
var callResult either.Either[[]byte, string]
if perr := resp.Msg.GetError(); perr != nil {
failed := false
if err != nil {
logger.Warnf("Async call could not be called: %v", err)
callResult = either.RightOf[[]byte](err.Error())
failed = true
} else if perr := resp.Msg.GetError(); perr != nil {
logger.Warnf("Async call failed: %s", perr.Message)
callResult = either.RightOf[[]byte](perr.Message)
failed = true
} else {
logger.Debugf("Async call succeeded")
callResult = either.LeftOf[string](resp.Msg.GetBody())
}
err = s.dal.CompleteAsyncCall(ctx, call, callResult, func(tx *dal.Tx) error {
failed := resp.Msg.GetError() != nil
if failed && call.RemainingAttempts > 0 {
// Will retry, do not propagate failure yet.
return nil
Expand Down

0 comments on commit ff51164

Please sign in to comment.