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

Google Cloud Pub/Sub gRPC: acknowledge flow #2422

Merged
merged 3 commits into from
Sep 22, 2020

Conversation

ennru
Copy link
Member

@ennru ennru commented Sep 21, 2020

@probot-autolabeler probot-autolabeler bot added dependency-change For PRs changing the version of a dependency. p:google-cloud-pub-sub-grpc labels Sep 21, 2020
@ennru ennru changed the title Pubsub grpc ack flow Google Cloud Pub/Sub gRPC: acknowledge flow Sep 21, 2020
Copy link
Member

@seglo seglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left some comments.

/**
* Create a sink that accepts consumed message acknowledgements.
*
* The materialized value completes on stream completion.
*
* @param parallelism controls how many acknowledgements can be in-flight at any given time
*/
def acknowledge(parallelism: Int): Sink[AcknowledgeRequest, Future[Done]] =
def acknowledge(parallelism: Int): Sink[AcknowledgeRequest, Future[Done]] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this method be deprecated like its javadsl counterpart?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was in the non-gRPC version.

Comment on lines +100 to +111
def acknowledgeFlow(): Flow[AcknowledgeRequest, AcknowledgeRequest, NotUsed] =
Flow
.setup { (mat, attr) =>
Flow[AcknowledgeRequest]
.mapAsync(1)(
req =>
subscriber(mat, attr).client
.acknowledge(req)
.map(_ => req)(mat.executionContext)
)
}
.mapMaterializedValue(_ => NotUsed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there's an opportunity here to compose all the acknowledge sink/flow and java/scala DSL methods from this to DRY up the impls. It could be refactored into a private method that takes parallelism to support the deprecated overloads.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gRPC generated types are different for the Java DSL and the Scala DSL. That's not easy to see.

@@ -238,7 +238,7 @@ object Dependencies {
"com.google.auth" % "google-auth-library-oauth2-http" % "0.20.0", // BSD 3-clause
// pull in Akka Discovery for our Akka version
"com.typesafe.akka" %% "akka-discovery" % AkkaVersion
) ++ Silencer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] Curious as to why the Silencer dep usage was moved to build.sbt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was that it is not a dependency. It's just build infrastructure. I'll move it back.

.setup { (mat, attr) =>
Flow
.create[AcknowledgeRequest]
.mapAsyncUnordered(1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] I suppose this could just be mapAsync if parallelism always equals 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, mapAsync with parallelism 1 falls back to the mapAsyncUnordered implementation anyway.

@ennru ennru merged commit 583899a into akka:master Sep 22, 2020
@ennru ennru deleted the pubsub-grpc-ack-flow branch September 22, 2020 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency-change For PRs changing the version of a dependency. p:google-cloud-pub-sub-grpc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants