Class CloudEventBatch
- Namespace
- Excalibur.Dispatch.CloudEvents
- Assembly
- Excalibur.Dispatch.dll
Represents a batch of CloudEvents for efficient bulk processing. Implements the CloudEvents Batch Format specification.
public sealed class CloudEventBatch : IReadOnlyList<CloudEvent>, IReadOnlyCollection<CloudEvent>, IEnumerable<CloudEvent>, IEnumerable
- Inheritance
-
CloudEventBatch
- Implements
- Inherited Members
- Extension Methods
Constructors
CloudEventBatch()
Initializes a new instance of the CloudEventBatch class with default options.
public CloudEventBatch()
CloudEventBatch(CloudEventBatchOptions?)
Initializes a new instance of the CloudEventBatch class.
public CloudEventBatch(CloudEventBatchOptions? options)
Parameters
optionsCloudEventBatchOptions
CloudEventBatch(IEnumerable<CloudEvent>, CloudEventBatchOptions?)
Initializes a new instance of the CloudEventBatch class. Initializes a new instance with existing events.
public CloudEventBatch(IEnumerable<CloudEvent> events, CloudEventBatchOptions? options = null)
Parameters
eventsIEnumerable<CloudEvent>optionsCloudEventBatchOptions
Properties
Count
Gets the number of events in the batch.
public int Count { get; }
Property Value
- int
The count of events currently queued in the batch.
CurrentBatchSize
Gets the current estimated size of the batch in bytes.
public long CurrentBatchSize { get; }
Property Value
- long
The cumulative size estimate for events currently in the batch.
this[int]
Gets the CloudEvent at the specified index.
public CloudEvent this[int index] { get; }
Parameters
indexintZero-based index of the event to retrieve.
Property Value
MaxBatchSize
Gets the maximum total size in bytes for this batch.
public long MaxBatchSize { get; }
Property Value
- long
The configured maximum batch size expressed in bytes.
MaxEvents
Gets the maximum number of events allowed in this batch.
public int MaxEvents { get; }
Property Value
- int
The limit on the number of events permitted in the batch.
Methods
AddRange(IEnumerable<CloudEvent>)
Adds multiple CloudEvents to the batch.
public int AddRange(IEnumerable<CloudEvent> events)
Parameters
eventsIEnumerable<CloudEvent>
Returns
- int
The number of events successfully added.
Clear()
Clears all events from the batch.
public void Clear()
GetEnumerator()
Returns an enumerator that iterates through the cloud events in this batch.
public IEnumerator<CloudEvent> GetEnumerator()
Returns
- IEnumerator<CloudEvent>
An enumerator for the cloud events.
Split()
Splits the current batch into multiple batches if needed.
public IReadOnlyList<CloudEventBatch> Split()
Returns
TryAdd(CloudEvent)
Attempts to add a CloudEvent to the batch.
public bool TryAdd(CloudEvent cloudEvent)
Parameters
cloudEventCloudEvent
Returns
- bool
True if the event was added; false if it would exceed batch limits.