pub struct HttpSource { /* private fields */ }Expand description
HTTP source with configurable adaptive batching.
This source exposes HTTP endpoints for receiving data change events. It supports both single-event and batch submission modes, with adaptive batching for optimized throughput.
§Fields
base: Common source functionality (dispatchers, status, lifecycle)config: HTTP-specific configuration (host, port, timeout)adaptive_config: Adaptive batching settings for throughput optimization
Implementations§
Source§impl HttpSource
impl HttpSource
Sourcepub fn new(id: impl Into<String>, config: HttpSourceConfig) -> Result<Self>
pub fn new(id: impl Into<String>, config: HttpSourceConfig) -> Result<Self>
Create a new HTTP source.
The event channel is automatically injected when the source is added
to DrasiLib via add_source().
§Arguments
id- Unique identifier for this source instanceconfig- HTTP source configuration
§Returns
A new HttpSource instance, or an error if construction fails.
§Errors
Returns an error if the base source cannot be initialized.
§Example
use drasi_source_http::{HttpSource, HttpSourceBuilder};
let config = HttpSourceBuilder::new()
.with_host("0.0.0.0")
.with_port(8080)
.build();
let source = HttpSource::new("my-http-source", config)?;Sourcepub fn with_dispatch(
id: impl Into<String>,
config: HttpSourceConfig,
dispatch_mode: Option<DispatchMode>,
dispatch_buffer_capacity: Option<usize>,
) -> Result<Self>
pub fn with_dispatch( id: impl Into<String>, config: HttpSourceConfig, dispatch_mode: Option<DispatchMode>, dispatch_buffer_capacity: Option<usize>, ) -> Result<Self>
Create a new HTTP source with custom dispatch settings.
The event channel is automatically injected when the source is added
to DrasiLib via add_source().
§Arguments
id- Unique identifier for this source instanceconfig- HTTP source configurationdispatch_mode- Optional dispatch mode (Channel, Direct, etc.)dispatch_buffer_capacity- Optional buffer capacity for channel dispatch
§Returns
A new HttpSource instance with custom dispatch settings.
§Errors
Returns an error if the base source cannot be initialized.
Source§impl HttpSource
impl HttpSource
Sourcepub fn builder(id: impl Into<String>) -> HttpSourceBuilder
pub fn builder(id: impl Into<String>) -> HttpSourceBuilder
Create a builder for HttpSource with the given ID.
This is the recommended way to construct an HttpSource.
§Arguments
id- Unique identifier for the source instance
§Example
let source = HttpSource::builder("my-source")
.with_host("0.0.0.0")
.with_port(8080)
.with_bootstrap_provider(my_provider)
.build()?;