Replace host and port parameters with unified endpoint parameter for HTTP and MQTT connections#4706
Replace host and port parameters with unified endpoint parameter for HTTP and MQTT connections#4706
Conversation
|
@fgalan 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
…n functions Co-authored-by: fgalan <[email protected]>
Co-authored-by: fgalan <[email protected]>
Co-authored-by: fgalan <[email protected]>
endpoint as the way to define the connection destination for HTTP and MQTT. Replacing parameters host and port|
@copilot I don't like this solution proposal too much... Instead of The endpoint parameters should come set from the very beginning, instead of building if from port and host. In other words, host and port should not be needed at this point. |
- Add overloaded parseUrl function that also extracts endpoint directly - Update Notifier.cpp to use endpoint from parseUrl instead of buildEndpoint - Add comprehensive unit tests for new parseUrl overload - Addresses feedback: endpoint comes from the beginning, no host/port roundtrip Co-authored-by: fgalan <[email protected]>
You're absolutely right! I've addressed this by adding an overloaded version of The change ensures the endpoint parameter comes from the very beginning of the URL parsing process, so host and port are no longer needed at the point where we build the The commit 5111726 implements this optimization. |
This PR replaces separate
hostandportparameters with a singleendpointparameter for HTTP and MQTT connections, unifying the configuration approach with the Kafka connection feature introduced in issue #4666.Changes Made
Core Structure Updates
ipandportfields with a unifiedendpointfield (format: "host:port")sendMqttNotification()andgetConnection()to accept endpoint parameter instead of separate host/portNew Helper Functions
Added utility functions in
src/lib/common/string.h:buildEndpoint(host, port)- Constructs endpoint string from host and portparseEndpoint(endpoint, host, port)- Parses endpoint string back to host and port with IPv6 supportparseUrl(url, host, port, path, protocol, endpoint)- Overloaded version that extracts endpoint directlyUpdated Flow
Notifier.cppuses overloadedparseUrl()to extract endpoint directly from URL parsingSenderThreadParamsstores single endpoint stringdoNotify.cppparses endpoint for HTTP calls or passes directly to MQTTBenefits
Backward Compatibility
httpRequestSend()function signature unchanged to minimize impactTesting
Fixes #4705.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.