public OpenKitInitializer(IOpenKitBuilder builder)
        {
            logger = builder.Logger;
            privacyConfiguration = PrivacyConfiguration.From(builder);
            openKitConfiguration = OpenKitConfiguration.From(builder);

            timingProvider    = new DefaultTimingProvider();
            threadIdProvider  = new DefaultThreadIdProvider();
            sessionIdProvider = new DefaultSessionIdProvider();

            beaconCache        = new BeaconCache(logger);
            beaconCacheEvictor = new BeaconCacheEvictor(logger, beaconCache, BeaconCacheConfiguration.From(builder),
                                                        timingProvider);

            var httpClientConfig = HttpClientConfiguration.From(openKitConfiguration);
            // shared thread suspender between BeaconSender and HttpClient. HttpClient will be woken up when
            // BeaconSender shuts down
            var beaconSenderThreadSuspender = new InterruptibleThreadSuspender();

            beaconSender = new BeaconSender(
                logger,
                httpClientConfig,
                new DefaultHttpClientProvider(logger, beaconSenderThreadSuspender),
                timingProvider,
                beaconSenderThreadSuspender);
            var watchdogThreadSuspender = new InterruptibleThreadSuspender();

            sessionWatchdog = new SessionWatchdog(
                logger,
                new SessionWatchdogContext(timingProvider, watchdogThreadSuspender));
        }
示例#2
0
        private IBeaconCacheConfiguration MockBeaconCacheConfig(long maxRecordAge, long lowerSizeBound, long upperSizeBound)
        {
            var builder = Substitute.For <IOpenKitBuilder>();

            builder.BeaconCacheMaxBeaconAge.Returns(maxRecordAge);
            builder.BeaconCacheLowerMemoryBoundary.Returns(lowerSizeBound);
            builder.BeaconCacheUpperMemoryBoundary.Returns(upperSizeBound);

            var config = BeaconCacheConfiguration.From(builder);

            return(config);
        }