Skip to content

Commit

Permalink
Apply trailer only optimization for responseForSingleElement (#396)
Browse files Browse the repository at this point in the history
* apply trailer only optimization for responseForSingleElement

* remove unused import
  • Loading branch information
NavidJalali authored Oct 31, 2024
1 parent fa1bfff commit e616c6a
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import pekko.http.scaladsl.model.HttpEntity.ChunkStreamPart
import pekko.http.scaladsl.model.{ HttpEntity, HttpResponse, Trailer }
import pekko.stream.Materializer
import pekko.stream.scaladsl.Source
import pekko.util.ByteString
import io.grpc.Status

import scala.collection.immutable
Expand Down Expand Up @@ -60,12 +59,7 @@ object GrpcResponseHelpers {
val responseHeaders = headers.`Message-Encoding`(writer.messageEncoding.name) :: Nil
try writer.encodeDataToResponse(m.serialize(e), responseHeaders, TrailerOkAttribute)
catch {
case NonFatal(ex) =>
val trailers = GrpcEntityHelpers.handleException(ex, eHandler)
writer.encodeDataToResponse(
ByteString.empty,
responseHeaders,
Trailer(GrpcEntityHelpers.trailer(trailers.status, trailers.metadata).trailers))
case NonFatal(ex) => status(GrpcEntityHelpers.handleException(ex, eHandler))
}
}

Expand Down

0 comments on commit e616c6a

Please sign in to comment.