func main() { config := siesta.NewConnectorConfig() config.BrokerList = []string{"localhost:9092"} client, err := siesta.NewDefaultConnector(config) if err != nil { panic(err) } consumer := gonzo.NewConsumer(client, gonzo.NewConsumerConfig(), consumerStrategy) consumer.Add("gonzo", 0) consumer.Add("gonzo", 1) consumer.Join() }
func (kc *KafkaConsumer) Start() (<-chan *gonzo.MessageAndMetadata, error) { config := siesta.NewConnectorConfig() config.BrokerList = kc.brokerList client, err := siesta.NewDefaultConnector(config) if err != nil { return nil, err } consumerConfig := gonzo.NewConsumerConfig() kc.consumer = gonzo.NewConsumer(client, consumerConfig, kc.messageCallback) for _, partition := range kc.partitions { for _, topic := range kc.topics { kc.consumer.Add(topic, partition) } } return kc.messages, nil }