func logLineProtoStrategy(_ *kafka.Worker, msg *kafka.Message, id kafka.TaskId) kafka.WorkerResult { line := &sp.LogLine{} proto.Unmarshal(msg.Value, line) timings <- line.Timings return kafka.NewSuccessfulResult(id) }
func GetStrategy(consumerId string) func(*kafkaClient.Worker, *kafkaClient.Message, kafkaClient.TaskId) kafkaClient.WorkerResult { consumeRate := metrics.NewRegisteredMeter(fmt.Sprintf("%s-ConsumeRate", consumerId), metrics.DefaultRegistry) return func(_ *kafkaClient.Worker, msg *kafkaClient.Message, id kafkaClient.TaskId) kafkaClient.WorkerResult { kafkaClient.Tracef("main", "Got a message: %s", string(msg.Value)) consumeRate.Mark(1) return kafkaClient.NewSuccessfulResult(id) } }
func avroStrategy(_ *kafka.Worker, msg *kafka.Message, id kafka.TaskId) kafka.WorkerResult { record := msg.DecodedValue.(*avro.GenericRecord) newTimings := make([]int64, 0) for _, timing := range record.Get("timings").([]interface{}) { newTimings = append(newTimings, timing.(int64)) } timings <- newTimings return kafka.NewSuccessfulResult(id) }
func avroStrategy(_ *kafka.Worker, msg *kafka.Message, id kafka.TaskId) kafka.WorkerResult { record := msg.DecodedValue.(*avro.GenericRecord) messageTimings := record.Get("timings").([]interface{}) for _, timing := range msg.DecodedKey.([]int64) { messageTimings = append(messageTimings, timing) } messageTimings = append(messageTimings, time.Now().UnixNano()/int64(time.Millisecond)) record.Set("timings", messageTimings) producer.Input() <- &kafka.ProducerMessage{Topic: *produceTopic, Value: record} return kafka.NewSuccessfulResult(id) }
func logLineProtoStrategy(_ *kafka.Worker, msg *kafka.Message, id kafka.TaskId) kafka.WorkerResult { line := &sp.LogLine{} proto.Unmarshal(msg.Value, line) line.Timings = append(line.Timings, msg.DecodedKey.([]int64)...) line.Timings = append(line.Timings, time.Now().UnixNano()/int64(time.Millisecond)) bytes, err := proto.Marshal(line) if err != nil { panic(err) } producer.Input() <- &kafka.ProducerMessage{Topic: *produceTopic, Value: bytes} return kafka.NewSuccessfulResult(id) }