private TopologyTestDriver(InternalTopologyBuilder builder, IStreamConfig config) { this.topologyBuilder = builder; this.configuration = config; // ONLY 1 thread for test driver this.configuration.NumStreamThreads = 1; this.configuration.Guarantee = ProcessingGuarantee.AT_LEAST_ONCE; this.topicConfiguration = config.Clone(); this.topicConfiguration.ApplicationId = $"test-driver-{this.configuration.ApplicationId}"; var processID = Guid.NewGuid(); var clientId = string.IsNullOrEmpty(configuration.ClientId) ? $"{this.configuration.ApplicationId.ToLower()}-{processID}" : configuration.ClientId; this.configuration.ClientId = clientId; kafkaSupplier = new MockKafkaSupplier(); pipeBuilder = new PipeBuilder(kafkaSupplier); this.processorTopology = this.topologyBuilder.BuildTopology(); this.threadTopology = StreamThread.Create( $"{this.configuration.ApplicationId.ToLower()}-stream-thread-0", clientId, builder, config, kafkaSupplier, kafkaSupplier.GetAdmin(configuration.ToAdminConfig($"{clientId}-admin")), 0); RunDriver(); }
internal TopologyTestDriver(InternalTopologyBuilder builder, IStreamConfig config, Mode mode, IKafkaSupplier supplier) { topologyBuilder = builder; configuration = config; // ONLY 1 thread for test driver (use only for ASYNC_CLUSTER_IN_MEMORY) configuration.NumStreamThreads = 1; configuration.Guarantee = ProcessingGuarantee.AT_LEAST_ONCE; topicConfiguration = config.Clone(); topicConfiguration.ApplicationId = $"test-driver-{configuration.ApplicationId}"; var clientId = string.IsNullOrEmpty(configuration.ClientId) ? $"{configuration.ApplicationId.ToLower()}-{Guid.NewGuid()}" : configuration.ClientId; // sanity check topologyBuilder.BuildTopology(); topologyBuilder.RewriteTopology(configuration); switch (mode) { case Mode.SYNC_TASK: behavior = new TaskSynchronousTopologyDriver( clientId, topologyBuilder, configuration, topicConfiguration, supplier, tokenSource.Token); break; case Mode.ASYNC_CLUSTER_IN_MEMORY: behavior = new ClusterInMemoryTopologyDriver( clientId, topologyBuilder, configuration, topicConfiguration, supplier, tokenSource.Token); break; } behavior.StartDriver(); }