···167167 /// When reconnecting, use the time_us from your most recently processed event and maybe
168168 /// provide a negative buffer (i.e. subtract a few seconds) to ensure gapless playback.
169169 pub cursor: Option<chrono::DateTime<Utc>>,
170170+ /// Maximum size of send channel for jetstream events.
171171+ ///
172172+ /// If your consuming task can't keep up with every new jetstream event in real-time,
173173+ /// you might get disconnected from the server as a "slow consumer". Increasing channel_size
174174+ /// can help prevent that if your consumer sometimes pauses, at a cost of higher memory
175175+ /// usage while events are buffered.
176176+ pub channel_size: usize,
170177 /// Marker for record deserializable type.
171178 ///
172179 /// See examples/arbitrary_record.rs for an example using serde_json::Value
···184191 wanted_dids: Vec::new(),
185192 compression: JetstreamCompression::None,
186193 cursor: None,
194194+ channel_size: 1024,
187195 record_type: PhantomData,
188196 }
189197 }
···266274 .validate()
267275 .map_err(ConnectionError::InvalidConfig)?;
268276269269- // TODO: Run some benchmarks and look into using a bounded channel instead.
270270- let (send_channel, receive_channel) = flume::unbounded();
277277+ let (send_channel, receive_channel) = flume::bounded(self.config.channel_size);
271278272279 let configured_endpoint = self
273280 .config