mdedetrich commented on code in PR #165:
URL:
https://github.com/apache/incubator-pekko-connectors/pull/165#discussion_r1225758883
##########
google-cloud-pub-sub-grpc/src/main/scala/org/apache/pekko/stream/connectors/googlecloud/pubsub/grpc/javadsl/GooglePubSub.scala:
##########
@@ -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]] {
Review Comment:
> Apologies, I'm not familiar with the term 'SAM'. Could you give me the
full name?
SAM = Single Abstract Method, terminology introduced in Java 1.8 which means
a class with just a single method aka an anonymous function. It allows the
boilerplate reduction of having to manually create a class with a method (which
is whats happening here).
What @He-Pin is saying is that you can probably replace
```scala
new function.Function[StreamingPullResponse,
java.util.List[ReceivedMessage]] {
override def apply(response: StreamingPullResponse):
java.util.List[ReceivedMessage] =
response.getReceivedMessagesList
})
```
With just
```scala
(response: StreamingPullResponse) => response.getReceivedMessagesList
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]