pub struct HttpUsageEmitter { /* private fields */ }Expand description
Posts usage events to an HTTP endpoint in bounded batches, retrying and optionally spooling to disk when the endpoint is unavailable.
UpdateSent events are not posted one per message. Updates for the same
connection, deployment, identity and view are summed over a 10-second
window and posted as one event carrying the total messages and bytes,
stamped with the time of the last update it covers. Consumers should sum
those fields rather than count events. Every other event type is posted
as emitted.
Implementations§
Source§impl HttpUsageEmitter
impl HttpUsageEmitter
pub fn new(endpoint: String, auth_token: Option<String>) -> Self
pub fn new_attributed( endpoint: String, auth_token: Option<String>, build_id: impl Into<String>, ) -> Result<Self, InvalidUsageBuildId>
pub fn with_spool_dir( endpoint: String, auth_token: Option<String>, spool_dir: impl Into<PathBuf>, ) -> Self
pub fn with_attributed_spool_dir( endpoint: String, auth_token: Option<String>, spool_dir: impl Into<PathBuf>, build_id: impl Into<String>, ) -> Result<Self, InvalidUsageBuildId>
pub fn with_config( endpoint: String, auth_token: Option<String>, batch_size: usize, flush_interval: Duration, ) -> Self
Trait Implementations§
Source§impl WebSocketUsageEmitter for HttpUsageEmitter
impl WebSocketUsageEmitter for HttpUsageEmitter
fn emit<'life0, 'async_trait>(
&'life0 self,
event: WebSocketUsageEvent,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for HttpUsageEmitter
impl RefUnwindSafe for HttpUsageEmitter
impl Send for HttpUsageEmitter
impl Sync for HttpUsageEmitter
impl Unpin for HttpUsageEmitter
impl UnsafeUnpin for HttpUsageEmitter
impl UnwindSafe for HttpUsageEmitter
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