-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MQTT support #98
Add MQTT support #98
Conversation
Warning Rate Limit Exceeded@tphakala has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 57 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe recent update introduces MQTT integration, enabling MQTT communication within the application. This enhancement includes adding MQTT settings in the configuration, creating an MQTT client for connecting and publishing messages, and integrating MQTT actions into the processing workflow. These changes expand the application's communication capabilities by allowing interaction with MQTT brokers for real-time message handling. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Review Status
Configuration used: CodeRabbit UI
Files ignored due to path filters (2)
go.mod
is excluded by!**/*.mod
go.sum
is excluded by!**/*.sum
Files selected for processing (5)
- internal/analysis/processor/actions.go (4 hunks)
- internal/analysis/processor/processor.go (3 hunks)
- internal/analysis/processor/workers.go (1 hunks)
- internal/conf/config.go (2 hunks)
- internal/mqtt/mqtt.go (1 hunks)
func (c *Client) Publish(topic string, payload string) error { | ||
if c.internalClient == nil { | ||
return errors.New("MQTT client is not initialized") | ||
} | ||
|
||
if c.internalClient.IsConnected() == false { | ||
return errors.New("MQTT client is not connected") | ||
} | ||
|
||
token := c.internalClient.Publish(topic, 0, false, payload) | ||
token.Wait() | ||
return token.Error() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add QoS (Quality of Service) and retain flag as configurable options for the Publish
method to enhance flexibility.
- func (c *Client) Publish(topic string, payload string) error {
+ func (c *Client) Publish(topic string, payload string, qos byte, retain bool) error {
- token := c.internalClient.Publish(topic, 0, false, payload)
+ token := c.internalClient.Publish(topic, qos, retain, payload)
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
func (c *Client) Publish(topic string, payload string) error { | |
if c.internalClient == nil { | |
return errors.New("MQTT client is not initialized") | |
} | |
if c.internalClient.IsConnected() == false { | |
return errors.New("MQTT client is not connected") | |
} | |
token := c.internalClient.Publish(topic, 0, false, payload) | |
token.Wait() | |
return token.Error() | |
func (c *Client) Publish(topic string, payload string, qos byte, retain bool) error { | |
if c.internalClient == nil { | |
return errors.New("MQTT client is not initialized") | |
} | |
if c.internalClient.IsConnected() == false { | |
return errors.New("MQTT client is not connected") | |
} | |
token := c.internalClient.Publish(topic, qos, retain, payload) | |
token.Wait() | |
return token.Error() |
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- internal/analysis/processor/processor.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- internal/analysis/processor/processor.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- internal/analysis/processor/actions.go (4 hunks)
Additional Context Used
GitHub Check Runs (1)
lint failure (10)
internal/analysis/processor/actions.go: [failure] 155-155:
undefined: errors (typecheck)
Additional comments not posted (1)
internal/analysis/processor/actions.go (1)
56-61
: TheMqttAction
struct is well-defined and appropriately structured for MQTT functionality.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Thank you! Merged and new release created containing this new feature. |
In response to feature request #83, I'm creating this PR to add MQTT detection publishing support.
I tested that it works, please give me a review @tphakala. Thanks
Summary by CodeRabbit