pub struct SendData { /* private fields */ }Expand description
SendData is a structure that holds the data to be sent to a target endpoint.
It includes the payloads to be sent, the size of the data, the target endpoint,
headers for the request, and a retry strategy for sending the data.
§Example
use libdd_trace_protobuf::pb::TracerPayload;
use libdd_trace_utils::send_data::{
SendData,
};
use libdd_common::Endpoint;
use libdd_common::http_common::new_default_client;
use libdd_trace_utils::send_with_retry::{RetryBackoffType, RetryStrategy};
use libdd_trace_utils::trace_utils::TracerHeaderTags;
use libdd_trace_utils::tracer_payload::TracerPayloadCollection;
#[cfg_attr(miri, ignore)]
async fn update_send_results_example() {
let size = 100;
let tracer_payload = TracerPayloadCollection::V07(
vec![TracerPayload::default()]); // Replace with actual payload
let tracer_header_tags = TracerHeaderTags::default(); // Replace with actual header tags
let target = Endpoint::default(); // Replace with actual endpoint
let mut send_data = SendData::new(size, tracer_payload, tracer_header_tags, &target);
// Set a custom retry strategy
let retry_strategy = RetryStrategy::new(3, 10, RetryBackoffType::Exponential, Some(5));
send_data.set_retry_strategy(retry_strategy);
let client = new_default_client();
// Send the data
let result = send_data.send(&client).await;
}Implementations§
Source§impl SendData
impl SendData
Sourcepub fn new(
size: usize,
tracer_payload: TracerPayloadCollection,
tracer_header_tags: TracerHeaderTags<'_>,
target: &Endpoint,
) -> SendData
pub fn new( size: usize, tracer_payload: TracerPayloadCollection, tracer_header_tags: TracerHeaderTags<'_>, target: &Endpoint, ) -> SendData
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the user defined approximate size of the data to be sent in bytes.
§Returns
The size of the data.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the user defined approximate size of the data to be sent is zero.
§Returns
true if size is 0, false otherwise.
Sourcepub fn get_target(&self) -> &Endpoint
pub fn get_target(&self) -> &Endpoint
Sourcepub fn get_payloads(&self) -> &TracerPayloadCollection
pub fn get_payloads(&self) -> &TracerPayloadCollection
Sourcepub fn set_retry_strategy(&mut self, retry_strategy: RetryStrategy)
pub fn set_retry_strategy(&mut self, retry_strategy: RetryStrategy)
Overrides the default RetryStrategy with user-defined values.
§Arguments
retry_strategy: The new retry strategy to be used.
Sourcepub async fn send<C: Connect>(
&self,
http_client: &GenericHttpClient<C>,
) -> SendDataResult
pub async fn send<C: Connect>( &self, http_client: &GenericHttpClient<C>, ) -> SendDataResult
Sends the data to the target endpoint.
§Returns
A SendDataResult instance containing the result of the operation.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SendData
impl RefUnwindSafe for SendData
impl Send for SendData
impl Sync for SendData
impl Unpin for SendData
impl UnsafeUnpin for SendData
impl UnwindSafe for SendData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more