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

chore: A bit less noise on gRPC journal client fail/reconnect #980

Merged
merged 4 commits into from
Aug 31, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import akka.projection.grpc.consumer.ConsumerFilter
import akka.projection.grpc.consumer.GrpcQuerySettings
import akka.projection.grpc.consumer.scaladsl
import akka.projection.grpc.consumer.scaladsl.GrpcReadJournal.withChannelBuilderOverrides
import akka.projection.grpc.internal.ConnectionException
import akka.projection.grpc.internal.ProtoAnySerialization
import akka.projection.grpc.internal.ProtobufProtocolConversions
import akka.projection.grpc.internal.proto
Expand All @@ -52,6 +53,7 @@ import akka.util.Timeout
import com.google.protobuf.Descriptors
import com.google.protobuf.timestamp.Timestamp
import com.typesafe.config.Config
import io.grpc.Status
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder
import org.slf4j.Logger
import org.slf4j.LoggerFactory
Expand All @@ -61,7 +63,6 @@ import java.util.concurrent.TimeUnit
import scala.collection.immutable
import scala.concurrent.ExecutionContext
import scala.concurrent.Future

@ApiMayChange
object GrpcReadJournal {
val Identifier = "akka.projection.grpc.consumer"
Expand Down Expand Up @@ -339,6 +340,13 @@ final class GrpcReadJournal private (
addRequestHeaders(client.eventsBySlices())
.invoke(streamIn)
.recover {
case ex: akka.grpc.GrpcServiceException if ex.status.getCode == Status.Code.UNAVAILABLE =>
// this means we couldn't connect, will be retried, relatively common, so make it less noisy
throw new ConnectionException(
clientSettings.serviceName,
clientSettings.servicePortName.getOrElse(clientSettings.defaultPort.toString),
streamId)

case th: Throwable =>
throw new RuntimeException(s"Failure to consume gRPC event stream for [${streamId}]", th)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) 2009-2023 Lightbend Inc. <https://www.lightbend.com>
*/

package akka.projection.grpc.internal

import akka.annotation.InternalApi

import scala.util.control.NoStackTrace

/**
* INTERNAL API
*/
@InternalApi
private[akka] final class ConnectionException(host: String, port: String, streamId: String)
extends RuntimeException(s"Connection to $host:$port for stream id $streamId failed or lost")
with NoStackTrace