Skip to content

Commit

Permalink
refactor: change variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdulsametileri committed Dec 5, 2022
1 parent 818462a commit 408c3aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/cronsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k *kafkaCronsumer) Listen(ctx context.Context, cancelFuncWrapper *func())
return
}

if msg.MessageUnixNanoTime >= startTimeUnixNano {
if msg.ProduceTime >= startTimeUnixNano {
(*cancelFuncWrapper)()

k.cfg.Logger.Info("Next iteration message has been detected, resending the message to exception")
Expand Down
14 changes: 7 additions & 7 deletions internal/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const (

type MessageWrapper struct {
kafka.Message
RetryCount int
MessageUnixNanoTime int64
RetryCount int
ProduceTime int64 // Nano time
}

func NewMessageWrapper(msg segmentio.Message) *MessageWrapper {
return &MessageWrapper{
RetryCount: getRetryCount(&msg),
MessageUnixNanoTime: getMessageUnixNanoTime(&msg),
RetryCount: getRetryCount(&msg),
ProduceTime: getMessageProduceTime(&msg),
Message: kafka.Message{
Topic: msg.Topic,
Partition: msg.Partition,
Expand All @@ -42,7 +42,7 @@ func NewMessageWrapper(msg segmentio.Message) *MessageWrapper {
func (m *MessageWrapper) To(increaseRetry bool) segmentio.Message {
if increaseRetry {
m.IncreaseRetryCount()
m.SetCreatedTime()
m.NewProduceTime()
}

return segmentio.Message{
Expand All @@ -63,7 +63,7 @@ func (m *MessageWrapper) IncreaseRetryCount() {
}
}

func (m *MessageWrapper) SetCreatedTime() {
func (m *MessageWrapper) NewProduceTime() {
for i := range m.Headers {
if m.Headers[i].Key == MessageProduceTimeHeaderKey {
m.Headers[i].Value = []byte(fmt.Sprint(time.Now().UnixNano()))
Expand Down Expand Up @@ -105,7 +105,7 @@ func getRetryCount(message *segmentio.Message) int {
return 0
}

func getMessageUnixNanoTime(message *segmentio.Message) int64 {
func getMessageProduceTime(message *segmentio.Message) int64 {
for i := range message.Headers {
if message.Headers[i].Key != MessageProduceTimeHeaderKey {
continue
Expand Down

0 comments on commit 408c3aa

Please sign in to comment.