|
22 | 22 | import java.util.concurrent.TimeUnit; |
23 | 23 | import java.util.concurrent.locks.ReentrantLock; |
24 | 24 |
|
25 | | -import io.split.android.client.common.CompressionUtilProvider; |
| 25 | +import io.split.android.client.streaming.support.CompressionUtilProvider; |
26 | 26 | import io.split.android.client.events.EventsManagerCoordinator; |
27 | 27 | import io.split.android.client.events.SplitInternalEvent; |
28 | 28 | import io.split.android.client.lifecycle.SplitLifecycleManager; |
|
54 | 54 | import io.split.android.client.service.sseclient.reactor.MySegmentsUpdateWorkerRegistry; |
55 | 55 | import io.split.android.client.service.sseclient.reactor.SplitUpdatesWorker; |
56 | 56 | import io.split.android.client.service.sseclient.sseclient.BackoffCounterTimer; |
| 57 | +import io.split.android.client.service.sseclient.sseclient.HttpFetcherStreamingAuthFetcher; |
| 58 | +import io.split.android.client.service.sseclient.sseclient.NotificationProcessorUpdateListener; |
57 | 59 | import io.split.android.client.service.sseclient.sseclient.PushNotificationManager; |
58 | 60 | import io.split.android.client.service.sseclient.sseclient.SseAuthenticator; |
59 | 61 | import io.split.android.client.service.sseclient.sseclient.SseClient; |
60 | | -import io.split.android.client.service.sseclient.sseclient.SseClientImpl; |
| 62 | +import io.split.android.client.service.sseclient.sseclient.HttpClientStreamingTransport; |
| 63 | +import io.split.android.client.service.sseclient.sseclient.DefaultSseClient; |
| 64 | +import io.split.android.client.service.sseclient.sseclient.EventSourceClientImpl; |
61 | 65 | import io.split.android.client.service.sseclient.sseclient.SseHandler; |
62 | 66 | import io.split.android.client.service.sseclient.sseclient.SseRefreshTokenTimer; |
| 67 | +import io.split.android.client.service.sseclient.sseclient.SplitTaskExecutorStreamingScheduler; |
63 | 68 | import io.split.android.client.service.sseclient.sseclient.StreamingComponents; |
| 69 | +import io.split.android.client.service.sseclient.sseclient.TelemetryRuntimeProducerStreamingTelemetry; |
| 70 | +import io.split.android.client.service.sseclient.spi.StreamingScheduler; |
| 71 | +import io.split.android.client.service.sseclient.spi.StreamingTelemetry; |
| 72 | +import io.split.android.client.service.sseclient.spi.UpdateNotificationListener; |
64 | 73 | import io.split.android.client.service.synchronizer.RolloutCacheManager; |
65 | 74 | import io.split.android.client.service.synchronizer.RolloutCacheManagerImpl; |
66 | 75 | import io.split.android.client.service.synchronizer.SyncGuardian; |
@@ -288,37 +297,41 @@ SyncManager buildSyncManager(SplitClientConfig config, |
288 | 297 | } |
289 | 298 |
|
290 | 299 | @NonNull |
291 | | - PushNotificationManager getPushNotificationManager(SplitTaskExecutor splitTaskExecutor, |
| 300 | + PushNotificationManager getPushNotificationManager(StreamingScheduler scheduler, |
292 | 301 | SseAuthenticator sseAuthenticator, |
293 | 302 | PushManagerEventBroadcaster pushManagerEventBroadcaster, |
294 | 303 | SseClient sseClient, |
295 | | - TelemetryRuntimeProducer telemetryRuntimeProducer, |
| 304 | + StreamingTelemetry telemetry, |
296 | 305 | long defaultSseConnectionDelayInSecs, |
297 | 306 | int sseDisconnectionDelayInSecs) { |
298 | 307 | return new PushNotificationManager(pushManagerEventBroadcaster, |
299 | 308 | sseAuthenticator, |
300 | 309 | sseClient, |
301 | | - new SseRefreshTokenTimer(splitTaskExecutor, pushManagerEventBroadcaster), |
302 | | - telemetryRuntimeProducer, |
| 310 | + new SseRefreshTokenTimer(scheduler, pushManagerEventBroadcaster), |
| 311 | + scheduler, |
| 312 | + telemetry, |
303 | 313 | defaultSseConnectionDelayInSecs, |
304 | 314 | sseDisconnectionDelayInSecs, |
305 | 315 | null); |
306 | 316 | } |
307 | 317 |
|
308 | 318 | public SseClient getSseClient(String streamingServiceUrlString, |
309 | 319 | NotificationParser notificationParser, |
310 | | - NotificationProcessor notificationProcessor, |
311 | | - TelemetryRuntimeProducer telemetryRuntimeProducer, |
| 320 | + UpdateNotificationListener updateListener, |
| 321 | + StreamingTelemetry telemetry, |
312 | 322 | PushManagerEventBroadcaster pushManagerEventBroadcaster, |
313 | 323 | HttpClient httpClient) { |
314 | 324 | SseHandler sseHandler = new SseHandler(notificationParser, |
315 | | - notificationProcessor, |
316 | | - telemetryRuntimeProducer, |
| 325 | + updateListener, |
| 326 | + telemetry, |
317 | 327 | pushManagerEventBroadcaster); |
318 | 328 |
|
319 | | - return new SseClientImpl(URI.create(streamingServiceUrlString), |
320 | | - httpClient, |
321 | | - new EventStreamParser(), |
| 329 | + EventSourceClientImpl eventSourceClient = new EventSourceClientImpl( |
| 330 | + new HttpClientStreamingTransport(httpClient), |
| 331 | + new EventStreamParser()); |
| 332 | + |
| 333 | + return new DefaultSseClient(URI.create(streamingServiceUrlString), |
| 334 | + eventSourceClient, |
322 | 335 | sseHandler); |
323 | 336 | } |
324 | 337 |
|
@@ -396,22 +409,25 @@ public StreamingComponents buildStreamingComponents(@NonNull SplitTaskExecutor s |
396 | 409 | notificationParser, splitsUpdateNotificationQueue); |
397 | 410 |
|
398 | 411 | PushManagerEventBroadcaster pushManagerEventBroadcaster = new PushManagerEventBroadcaster(); |
| 412 | + StreamingScheduler scheduler = new SplitTaskExecutorStreamingScheduler(splitTaskExecutor); |
| 413 | + StreamingTelemetry streamingTelemetry = new TelemetryRuntimeProducerStreamingTelemetry(storageContainer.getTelemetryStorage()); |
| 414 | + UpdateNotificationListener updateListener = new NotificationProcessorUpdateListener(notificationProcessor); |
399 | 415 |
|
400 | 416 | SseClient sseClient = getSseClient(config.streamingServiceUrl(), |
401 | 417 | notificationParser, |
402 | | - notificationProcessor, |
403 | | - storageContainer.getTelemetryStorage(), |
| 418 | + updateListener, |
| 419 | + streamingTelemetry, |
404 | 420 | pushManagerEventBroadcaster, |
405 | 421 | defaultHttpClient); |
406 | 422 |
|
407 | | - SseAuthenticator sseAuthenticator = new SseAuthenticator(splitApiFacade.getSseAuthenticationFetcher(), |
| 423 | + SseAuthenticator sseAuthenticator = new SseAuthenticator(new HttpFetcherStreamingAuthFetcher(splitApiFacade.getSseAuthenticationFetcher()), |
408 | 424 | new SseJwtParser(), flagsSpec); |
409 | 425 |
|
410 | | - PushNotificationManager pushNotificationManager = getPushNotificationManager(splitTaskExecutor, |
| 426 | + PushNotificationManager pushNotificationManager = getPushNotificationManager(scheduler, |
411 | 427 | sseAuthenticator, |
412 | 428 | pushManagerEventBroadcaster, |
413 | 429 | sseClient, |
414 | | - storageContainer.getTelemetryStorage(), |
| 430 | + streamingTelemetry, |
415 | 431 | config.defaultSSEConnectionDelay(), |
416 | 432 | config.sseDisconnectionDelay()); |
417 | 433 |
|
|
0 commit comments