예제 #1
0
파일: consumers.go 프로젝트: pkoro/go-kafka
func startNewConsumer(config kafkaClient.ConsumerConfig, topic string) *kafkaClient.Consumer {
	config.Strategy = GetStrategy(config.Consumerid)
	config.WorkerFailureCallback = FailedCallback
	config.WorkerFailedAttemptCallback = FailedAttemptCallback
	consumer := kafkaClient.NewConsumer(&config)
	topics := map[string]int{topic: config.NumConsumerFetchers}
	go func() {
		consumer.StartStatic(topics)
	}()
	return consumer
}
예제 #2
0
func startNewConsumer(config kafkaClient.ConsumerConfig, topic string, channel chan *api.Message) *kafkaClient.Consumer {

	// wait explicitly for topic to be created by the producer
	waitForTopicToBeReady(config, topic)

	config.Strategy = handleMessage(config.Consumerid, channel)
	config.WorkerFailureCallback = failedCallback
	config.WorkerFailedAttemptCallback = failedAttemptCallback
	//config.NumConsumerFetchers = 2
	consumer := kafkaClient.NewConsumer(&config)
	topics := map[string]int{topic: config.NumConsumerFetchers}

	go func() {
		consumer.StartStatic(topics)
	}()
	return consumer
}
예제 #3
0
파일: mirror.go 프로젝트: ruo91/syscol
func setupProtoConfig(config *kafka.ConsumerConfig) {
	config.Strategy = logLineProtoStrategy
}
예제 #4
0
파일: mirror.go 프로젝트: ruo91/syscol
func setupAvroConfig(config *kafka.ConsumerConfig) {
	config.ValueDecoder = kafka.NewKafkaAvroDecoder(*schemaRegistry)
	config.Strategy = avroStrategy
}