Skip to content

Conversation

@renaz6
Copy link
Member

@renaz6 renaz6 commented Feb 3, 2026

Closes #7

@renaz6 renaz6 requested a review from piccione99 February 3, 2026 19:48
@renaz6 renaz6 self-assigned this Feb 3, 2026
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 13.05638% with 293 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.66%. Comparing base (6b0e5af) to head (7b0a45c).

Files with missing lines Patch % Lines
internal/publisher/options.go 0.00% 141 Missing ⚠️
internal/publisher/publisher.go 0.00% 99 Missing ⚠️
internal/consumer/handler.go 27.50% 29 Missing ⚠️
internal/app/app.go 40.00% 12 Missing ⚠️
internal/publisher/config.go 0.00% 10 Missing ⚠️
internal/app/publisher.go 90.00% 1 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (67.66%) is below the target coverage (72.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #20       +/-   ##
===========================================
- Coverage   84.64%   67.66%   -16.99%     
===========================================
  Files          20       24        +4     
  Lines        1029     1373      +344     
===========================================
+ Hits          871      929       +58     
- Misses        141      427      +286     
  Partials       17       17               
Flag Coverage Δ
unittests 67.66% <13.05%> (-16.99%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renaz6 renaz6 requested a review from piccione99 February 9, 2026 20:11
Copy link
Collaborator

@piccione99 piccione99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few minor comments.

topic: "device-lifecycle"
- pattern: "device-status"
topic: "device-status"
- pattern: "*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for ease of use, we might want to just keep just the last pattern and topic (* and default-events) as the default route so we only need one route in our default kafka setup

}

consumer.client = client
consumer.handler = consumer.config.handler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change the WithMessageHandler option in options.go to directly set consumer.handler so we can remove the above line? (I think the consumerConfig object is superfluous and awkward, my bad. I can clean that up.)

h.emitLog(log.LevelError, "failed to produce WRP message", map[string]any{
"error": err.Error(),
})
return fmt.Errorf("production failed: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we say "produce failed" since "production failed" sounds more alarming

return fmt.Errorf("production failed: %w", err)
}

h.emitLog(log.LevelInfo, "successfully routed WRP message", map[string]any{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this debug since this will be extremely high volume

return outcome, fmt.Errorf("failed to produce message: %w", err)
}

p.metricEmitter.Notify(metrics.Event{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this "messsages_produced" and use "outcome" as a label? Then we can remove the metric on line 160 (and return outside the if statement) since that should cover errors and successes. Once we set up the metrics and inject them (that can be a separate PR), we probably want to define constants in metrics/fx.go and use them instead of hardcoding them. Given how particular prometheus is about labels. But the labels are fine for this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also generate metrics using a PublishEvent listener for the async messages. but that's fine to leave until the prometheus metrics are set up in the metrics package.

@renaz6 renaz6 requested a review from piccione99 February 10, 2026 22:54
}

// Emit metrics about the message being produced
p.metricEmitter.Notify(metrics.Event{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this metric add something different than the metric on line 169 or can we remove it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will resolve this in #26

opts := []publisher.Option{
// Observability
publisher.WithLogEmitter(in.LogEmitter),
publisher.WithMetricsEmitter(in.MetricEmitter),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI - since we are injecting the metric emitter instead of using the noop, we will get errors when we try to emit the metrics for the publisher, since they are missing. that's probably fine because the call to emit metrics is async so just that go routine will panic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will resolve this in #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Implement Basic Message Handler (aka "Splitter")

2 participants