pub struct Producer<'a, const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> { /* private fields */ }Implementations§
Source§impl<'a, const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Producer<'a, MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>
impl<'a, const MCACHE_DEPTH: usize, const CHUNK_COUNT: usize, const CHUNK_SIZE: usize> Producer<'a, MCACHE_DEPTH, CHUNK_COUNT, CHUNK_SIZE>
Sourcepub fn new(
mcache: &'a MCache<MCACHE_DEPTH>,
dcache: &'a DCache<CHUNK_COUNT, CHUNK_SIZE>,
fseq: &'a Fseq,
) -> Self
pub fn new( mcache: &'a MCache<MCACHE_DEPTH>, dcache: &'a DCache<CHUNK_COUNT, CHUNK_SIZE>, fseq: &'a Fseq, ) -> Self
Create a producer for a shared mcache/dcache pair.
Without flow control, this producer will freely overwrite chunks.
Use with_flow_control for backpressure.
Sourcepub fn with_flow_control(
mcache: &'a MCache<MCACHE_DEPTH>,
dcache: &'a DCache<CHUNK_COUNT, CHUNK_SIZE>,
fseq: &'a Fseq,
fctl: &'a Fctl,
) -> Self
pub fn with_flow_control( mcache: &'a MCache<MCACHE_DEPTH>, dcache: &'a DCache<CHUNK_COUNT, CHUNK_SIZE>, fseq: &'a Fseq, fctl: &'a Fctl, ) -> Self
Create a producer with credit-based flow control.
The producer will acquire a credit before allocating a chunk.
Initialize fctl with CHUNK_COUNT credits.
Sourcepub fn with_metrics(self, metrics: &'a Metrics) -> Self
pub fn with_metrics(self, metrics: &'a Metrics) -> Self
Attach metrics tracking to this producer.
Returns a new producer with the same configuration plus metrics.
Sourcepub fn publish(
&self,
payload: &[u8],
sig: u64,
ctl: u16,
ts: u32,
) -> Result<FragmentMetadata, TangoError>
pub fn publish( &self, payload: &[u8], sig: u64, ctl: u16, ts: u32, ) -> Result<FragmentMetadata, TangoError>
Publish a payload fragment and its metadata.
If flow control is enabled, returns TangoError::NoCredits when
no credits are available (consumer hasn’t caught up).
Sourcepub fn publish_blocking(
&self,
payload: &[u8],
sig: u64,
ctl: u16,
ts: u32,
) -> Result<FragmentMetadata, TangoError>
pub fn publish_blocking( &self, payload: &[u8], sig: u64, ctl: u16, ts: u32, ) -> Result<FragmentMetadata, TangoError>
Try to publish, spinning until credits are available or mcache stops.
Only useful when flow control is enabled.
Sourcepub fn publish_batch(&self, payloads: &[&[u8]], sig: u64, ctl: u16) -> usize
pub fn publish_batch(&self, payloads: &[&[u8]], sig: u64, ctl: u16) -> usize
Publish multiple payloads in a batch.
Returns the number of successfully published messages.
Stops on the first error (e.g., NoCredits).
This can be more efficient than calling publish() in a loop
as it reduces function call overhead.