func parseAndValidateArgs() *kafka.MirrorMakerConfig { flag.Var(&consumerConfig, "consumer.config", "Path to consumer configuration file.") flag.Parse() runtime.GOMAXPROCS(*maxProcs) if (*whitelist != "" && *blacklist != "") || (*whitelist == "" && *blacklist == "") { fmt.Println("Exactly one of whitelist or blacklist is required.") os.Exit(1) } if *producerConfig == "" { fmt.Println("Producer config is required.") os.Exit(1) } if len(consumerConfig) == 0 { fmt.Println("At least one consumer config is required.") os.Exit(1) } if *queueSize < 0 { fmt.Println("Queue size should be equal or greater than 0") os.Exit(1) } if *timingsProducerConfig == "" && *schemaRegistryUrl == "" { fmt.Println("--schema.registry.url parameter is required when --timings is used") } config := kafka.NewMirrorMakerConfig() config.Blacklist = *blacklist config.Whitelist = *whitelist config.ChannelSize = *queueSize config.ConsumerConfigs = []string(consumerConfig) config.NumProducers = *numProducers config.NumStreams = *numStreams config.PreservePartitions = *preservePartitions config.PreserveOrder = *preserveOrder config.ProducerConfig = *producerConfig config.TopicPrefix = *prefix if *schemaRegistryUrl != "" { config.KeyEncoder = kafka.NewKafkaAvroEncoder(*schemaRegistryUrl) config.ValueEncoder = kafka.NewKafkaAvroEncoder(*schemaRegistryUrl) config.KeyDecoder = kafka.NewKafkaAvroDecoder(*schemaRegistryUrl) config.ValueDecoder = kafka.NewKafkaAvroDecoder(*schemaRegistryUrl) } config.TimingsProducerConfig = *timingsProducerConfig return config }
func parseAndValidateArgs() *kafka.MirrorMakerConfig { flag.Var(&consumerConfig, "consumer.config", "Path to consumer configuration file.") flag.Parse() runtime.GOMAXPROCS(*maxProcs) if (*whitelist != "" && *blacklist != "") || (*whitelist == "" && *blacklist == "") { fmt.Println("Exactly one of whitelist or blacklist is required.") os.Exit(1) } if *producerConfig == "" { fmt.Println("Producer config is required.") os.Exit(1) } if len(consumerConfig) == 0 { fmt.Println("At least one consumer config is required.") os.Exit(1) } if *queueSize < 0 { fmt.Println("Queue size should be equal or greater than 0") os.Exit(1) } config := kafka.NewMirrorMakerConfig() config.Blacklist = *blacklist config.Whitelist = *whitelist config.ChannelSize = *queueSize config.ConsumerConfigs = []string(consumerConfig) config.NumProducers = *numProducers config.NumStreams = *numStreams config.PreservePartitions = *preservePartitions config.PreserveOrder = *preserveOrder config.ProducerConfig = *producerConfig config.TopicPrefix = *prefix return config }