@@ -34,7 +34,7 @@ import com.snowplowanalytics.snowplow.pubsub.GcpUserAgent
34
34
import com .snowplowanalytics .snowplow .sources .SourceAndAck
35
35
import com .snowplowanalytics .snowplow .sources .internal .{Checkpointer , LowLevelEvents , LowLevelSource }
36
36
37
- import scala .concurrent .duration .{Duration , DurationDouble , FiniteDuration }
37
+ import scala .concurrent .duration .{DurationDouble , FiniteDuration }
38
38
import scala .jdk .CollectionConverters ._
39
39
40
40
import java .util .concurrent .{ExecutorService , Executors , LinkedBlockingQueue }
@@ -92,7 +92,7 @@ object PubsubSourceV2 {
92
92
(hotswap, _) <- Stream .resource(Hotswap (resource))
93
93
fs2Queue <- Stream .eval(Queue .synchronous[F , SubscriberAction ])
94
94
_ <- extendDeadlines(config, stub, refStates, channelAffinity).spawn
95
- _ <- Stream .eval(queueToQueue(config, jQueue, fs2Queue, stub, channelAffinity )).repeat.spawn
95
+ _ <- Stream .eval(queueToQueue(config, jQueue, fs2Queue)).repeat.spawn
96
96
lle <- Stream
97
97
.fromQueueUnterminated(fs2Queue)
98
98
.through(toLowLevelEvents(config, refStates, hotswap, resource, channelAffinity))
@@ -102,27 +102,12 @@ object PubsubSourceV2 {
102
102
private def queueToQueue [F [_]: Async ](
103
103
config : PubsubSourceConfigV2 ,
104
104
jQueue : LinkedBlockingQueue [SubscriberAction ],
105
- fs2Queue : QueueSink [F , SubscriberAction ],
106
- stub : SubscriberStub ,
107
- channelAffinity : Int
105
+ fs2Queue : QueueSink [F , SubscriberAction ]
108
106
): F [Unit ] =
109
107
resolveNextAction(jQueue).flatMap {
110
- case action @ SubscriberAction .ProcessRecords (records, controller, _) =>
111
- val fallback = if (config.modackOnProgressTimeout) {
112
- val ackIds = records.map(_.getAckId)
113
- if (config.cancelOnProgressTimeout)
114
- Logger [F ].debug(s " Cancelling Pubsub channel $channelAffinity for not making progress " ) *>
115
- Sync [F ].delay(controller.cancel()) *> Utils .modAck(config.subscription, stub, ackIds, Duration .Zero , channelAffinity)
116
- else
117
- Logger [F ].debug(s " Nacking on Pubsub channel $channelAffinity for not making progress " ) *>
118
- Sync [F ].delay(controller.request(1 )) *> Utils .modAck(config.subscription, stub, ackIds, Duration .Zero , channelAffinity)
119
- } else {
120
- if (config.cancelOnProgressTimeout)
121
- Logger [F ].debug(s " Cancelling Pubsub channel $channelAffinity for not making progress " ) *>
122
- Sync [F ].delay(controller.cancel()) *> fs2Queue.offer(action)
123
- else
124
- fs2Queue.offer(action)
125
- }
108
+ case action @ SubscriberAction .ProcessRecords (_, controller, _) =>
109
+ def fallback : F [Unit ] =
110
+ Sync [F ].delay(controller.request(0 )) *> fs2Queue.offer(action).timeoutTo(config.progressTimeout, fallback)
126
111
fs2Queue.offer(action).timeoutTo(config.progressTimeout, fallback)
127
112
case action : SubscriberAction .SubscriberError =>
128
113
fs2Queue.offer(action)
@@ -314,7 +299,7 @@ object PubsubSourceV2 {
314
299
val request = StreamingPullRequest .newBuilder
315
300
.setSubscription(config.subscription.show)
316
301
.setStreamAckDeadlineSeconds(config.durationPerAckExtension.toSeconds.toInt)
317
- .setClientId(if (config.consistentClientId) clientId.toString else UUID .randomUUID .toString)
302
+ .setClientId(clientId.toString)
318
303
.setMaxOutstandingMessages(0 )
319
304
.setMaxOutstandingBytes(0 )
320
305
.build
0 commit comments