|
Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
|
Stub UDP transport for testing. More...
#include <udp_transport.h>


Public Member Functions | |
| stub_udp_transport ()=default | |
| void | set_simulate_success (bool success) |
| Set whether to simulate success or failure. | |
| common::VoidResult | connect (const std::string &host, uint16_t port) override |
| Connect to a remote UDP endpoint. | |
| common::VoidResult | send (std::span< const uint8_t > data) override |
| Send data to the connected endpoint. | |
| bool | is_connected () const override |
| Check if connected to an endpoint. | |
| void | disconnect () override |
| Disconnect from the current endpoint. | |
| bool | is_available () const override |
| Check if transport is available. | |
| std::string | name () const override |
| Get transport name. | |
| udp_statistics | get_statistics () const override |
| Get transport statistics. | |
| void | reset_statistics () override |
| Reset statistics. | |
| std::string | get_host () const |
| uint16_t | get_port () const |
| common::VoidResult | send (const std::string &data) |
| Send string data to the connected endpoint. | |
Public Member Functions inherited from kcenon::monitoring::udp_transport | |
| virtual | ~udp_transport ()=default |
| common::VoidResult | send (const std::string &data) |
| Send string data to the connected endpoint. | |
Private Attributes | |
| std::string | host_ |
| uint16_t | port_ {0} |
| bool | connected_ {false} |
| bool | simulate_success_ {true} |
| std::atomic< std::size_t > | packets_sent_ {0} |
| std::atomic< std::size_t > | bytes_sent_ {0} |
| std::atomic< std::size_t > | send_failures_ {0} |
Stub UDP transport for testing.
This implementation simulates UDP sends without actual network calls. Useful for unit testing and when network is unavailable.
Definition at line 127 of file udp_transport.h.
|
default |
|
inlineoverridevirtual |
Connect to a remote UDP endpoint.
| host | Remote hostname or IP address |
| port | Remote port number |
Implements kcenon::monitoring::udp_transport.
Definition at line 150 of file udp_transport.h.
References connected_, kcenon::monitoring::host, host_, kcenon::monitoring::network_error, port_, and simulate_success_.
|
inlineoverridevirtual |
Disconnect from the current endpoint.
Implements kcenon::monitoring::udp_transport.
Definition at line 192 of file udp_transport.h.
References connected_, host_, and port_.
|
inline |
|
inline |
|
inlineoverridevirtual |
Get transport statistics.
Implements kcenon::monitoring::udp_transport.
Definition at line 206 of file udp_transport.h.
References bytes_sent_, packets_sent_, and send_failures_.
|
inlineoverridevirtual |
Check if transport is available.
Implements kcenon::monitoring::udp_transport.
Definition at line 198 of file udp_transport.h.
|
inlineoverridevirtual |
Check if connected to an endpoint.
Implements kcenon::monitoring::udp_transport.
Definition at line 188 of file udp_transport.h.
References connected_.
|
inlineoverridevirtual |
Get transport name.
Implements kcenon::monitoring::udp_transport.
Definition at line 202 of file udp_transport.h.
|
inlineoverridevirtual |
Reset statistics.
Implements kcenon::monitoring::udp_transport.
Definition at line 214 of file udp_transport.h.
References bytes_sent_, packets_sent_, and send_failures_.
|
inline |
Send string data to the connected endpoint.
| data | String data to send |
Definition at line 79 of file udp_transport.h.
|
inlineoverridevirtual |
Send data to the connected endpoint.
| data | Data to send |
Implements kcenon::monitoring::udp_transport.
Definition at line 164 of file udp_transport.h.
References bytes_sent_, connected_, kcenon::monitoring::network_error, packets_sent_, send_failures_, and simulate_success_.
|
inline |
Set whether to simulate success or failure.
Definition at line 146 of file udp_transport.h.
References simulate_success_, and kcenon::monitoring::success.
|
mutableprivate |
Definition at line 134 of file udp_transport.h.
Referenced by get_statistics(), reset_statistics(), and send().
|
private |
Definition at line 131 of file udp_transport.h.
Referenced by connect(), disconnect(), is_connected(), and send().
|
private |
Definition at line 129 of file udp_transport.h.
Referenced by connect(), disconnect(), and get_host().
|
mutableprivate |
Definition at line 133 of file udp_transport.h.
Referenced by get_statistics(), reset_statistics(), and send().
|
private |
Definition at line 130 of file udp_transport.h.
Referenced by connect(), disconnect(), and get_port().
|
mutableprivate |
Definition at line 135 of file udp_transport.h.
Referenced by get_statistics(), reset_statistics(), and send().
|
private |
Definition at line 132 of file udp_transport.h.
Referenced by connect(), send(), and set_simulate_success().