mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-19 08:01:16 +00:00
23 lines
491 B
Go
23 lines
491 B
Go
package jobs
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
cfk "github.com/confluentinc/confluent-kafka-go/v2/kafka"
|
|
"github.com/warmbly/warmbly/internal/models"
|
|
)
|
|
|
|
func (s *JobsService) Receive(msg *cfk.Message) error {
|
|
var event models.JobEvent
|
|
|
|
if err := s.Consumer.Avrov2.Deser.DeserializeInto(*msg.TopicPartition.Topic, msg.Value, &event); err != nil {
|
|
return err
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancel()
|
|
|
|
return s.HandleEvent(ctx, &event)
|
|
}
|