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

enable scala3 build for more google connectors #165

Merged
merged 9 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -17,6 +17,7 @@ import java.time.Duration
import java.util.concurrent.{ CompletableFuture, CompletionStage }
import org.apache.pekko
import pekko.actor.Cancellable
import pekko.japi.function
import pekko.stream.{ Attributes, Materializer }
import pekko.stream.javadsl.{ Flow, Keep, Sink, Source }
import pekko.{ Done, NotUsed }
Expand Down Expand Up @@ -61,15 +62,20 @@ object GooglePubSub {
.setStreamAckDeadlineSeconds(0)
.build()

subscriber(mat, attr).client
val streamingPullResult: Source[StreamingPullResponse, NotUsed] = subscriber(mat, attr).client
.streamingPull(
Source
.single(request)
.concat(
Source
.tick(Duration.ZERO, pollInterval, subsequentRequest)
.mapMaterializedValue(cancellable.complete(_))))
.mapConcat(_.getReceivedMessagesList)

streamingPullResult
.mapConcat(new function.Function[StreamingPullResponse, java.util.List[ReceivedMessage]] {
override def apply(response: StreamingPullResponse): java.util.List[ReceivedMessage] =
response.getReceivedMessagesList
})
.mapMaterializedValue(_ => cancellable)
}
.mapMaterializedValue(flattenCs(_))
Expand All @@ -92,12 +98,19 @@ object GooglePubSub {

val client = subscriber(mat, attr).client

Source
val sourceResult: Source[PullResponse, Cancellable] = Source
.tick(Duration.ZERO, pollInterval, request)
.mapAsync(1, client.pull(_))
.mapConcat(_.getReceivedMessagesList)

val concatResult: Source[ReceivedMessage, CompletableFuture[Cancellable]] = sourceResult
.mapConcat(new function.Function[PullResponse, java.util.List[ReceivedMessage]] {
override def apply(response: PullResponse): java.util.List[ReceivedMessage] =
response.getReceivedMessagesList
})
.mapMaterializedValue(cancellable.complete(_))
.mapMaterializedValue(_ => cancellable)

concatResult
}
.mapMaterializedValue(flattenCs(_))
.mapMaterializedValue(_.toCompletableFuture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object GrpcPublisher {
* An extension that manages a single gRPC java publisher client per actor system.
*/
final class GrpcPublisherExt private (sys: ExtendedActorSystem) extends Extension {
implicit val publisher = GrpcPublisher.create(sys)
implicit val publisher: GrpcPublisher = GrpcPublisher.create(sys)
}

object GrpcPublisherExt extends ExtensionId[GrpcPublisherExt] with ExtensionIdProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object GrpcSubscriber {
* An extension that manages a single gRPC java subscriber client per actor system.
*/
final class GrpcSubscriberExt private (sys: ExtendedActorSystem) extends Extension {
implicit val subscriber = GrpcSubscriber.create(sys)
implicit val subscriber: GrpcSubscriber = GrpcSubscriber.create(sys)
}

object GrpcSubscriberExt extends ExtensionId[GrpcSubscriberExt] with ExtensionIdProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object GrpcPublisher {
* An extension that manages a single gRPC scala publisher client per actor system.
*/
final class GrpcPublisherExt private (sys: ExtendedActorSystem) extends Extension {
implicit val publisher = GrpcPublisher(sys: ActorSystem)
implicit val publisher: GrpcPublisher = GrpcPublisher(sys: ActorSystem)
}

object GrpcPublisherExt extends ExtensionId[GrpcPublisherExt] with ExtensionIdProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object GrpcSubscriber {
* An extension that manages a single gRPC scala subscriber client per actor system.
*/
final class GrpcSubscriberExt private (sys: ExtendedActorSystem) extends Extension {
implicit val subscriber = GrpcSubscriber(sys: ActorSystem)
implicit val subscriber: GrpcSubscriber = GrpcSubscriber(sys: ActorSystem)
}

object GrpcSubscriberExt extends ExtensionId[GrpcSubscriberExt] with ExtensionIdProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class IntegrationSpec

implicit val system: ActorSystem = ActorSystem("IntegrationSpec")

implicit val defaultPatience = PatienceConfig(timeout = 15.seconds, interval = 50.millis)
implicit val defaultPatience: PatienceConfig = PatienceConfig(timeout = 15.seconds, interval = 50.millis)

"connector" should {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.apache.pekko.stream.connectors.google

import org.apache.pekko
import pekko.actor.ActorSystem
import pekko.NotUsed
import pekko.annotation.InternalApi
import pekko.http.scaladsl.model.HttpMethods.{ POST, PUT }
Expand Down
2 changes: 0 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ object Dependencies {
"io.specto" % "hoverfly-java" % hoverflyVersion % Test // ApacheV2
) ++ Mockito)
val GoogleBigQueryStorage = Seq(
crossScalaVersions -= Scala3,
// see Pekko gRPC version in plugins.sbt
libraryDependencies ++= Seq(
// https://github.com/googleapis/java-bigquerystorage/tree/master/proto-google-cloud-bigquerystorage-v1
Expand All @@ -241,7 +240,6 @@ object Dependencies {
) ++ Mockito)

val GooglePubSubGrpc = Seq(
crossScalaVersions -= Scala3,
// see Pekko gRPC version in plugins.sbt
libraryDependencies ++= Seq(
// https://github.com/googleapis/java-pubsub/tree/master/proto-google-cloud-pubsub-v1/
Expand Down