Skip to content

Commit dbeaa0b

Browse files
authored
Merge branch 'main' into release/v0.15.1
2 parents 3ec10ab + 160f7af commit dbeaa0b

File tree

7 files changed

+28
-19
lines changed

7 files changed

+28
-19
lines changed

crates/engineioxide/src/service/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! ## A tower [`Service`](tower::Service) for engine.io so it can be used with frameworks supporting tower services
1+
//! ## A tower [`Service`](tower_service::Service) for engine.io so it can be used with frameworks supporting tower services
22
//!
33
//!
44
//! #### Example with a `hyper` standalone service :

crates/engineioxide/src/socket.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -330,28 +330,38 @@ where
330330
.expect("Pong rx should be locked only once");
331331

332332
let instant = tokio::time::Instant::now();
333-
let mut interval_tick = tokio::time::interval(interval);
334-
interval_tick.tick().await;
335333
// Sleep for an interval minus the time it took to get here
336334
tokio::time::sleep(interval.saturating_sub(Duration::from_millis(
337335
15 + instant.elapsed().as_millis() as u64,
338336
)))
339337
.await;
340338

341339
#[cfg(feature = "tracing")]
342-
tracing::debug!("[sid={}] heartbeat sender routine started", self.id);
340+
tracing::debug!(sid = ?self.id, "heartbeat sender routine started");
343341

342+
let mut interval_tick = tokio::time::interval(interval);
343+
interval_tick.tick().await;
344+
// Some clients send the pong packet in first. If that happens, we should consume it.
345+
heartbeat_rx.try_recv().ok();
344346
loop {
345-
// Some clients send the pong packet in first. If that happens, we should consume it.
346-
heartbeat_rx.try_recv().ok();
347+
#[cfg(feature = "tracing")]
348+
tracing::trace!(sid = ?self.id, "emitting ping");
347349

348350
self.internal_tx
349351
.try_send(smallvec![Packet::Ping])
350352
.map_err(|_| Error::HeartbeatTimeout)?;
353+
354+
#[cfg(feature = "tracing")]
355+
tracing::trace!(sid = ?self.id, "waiting for pong");
356+
351357
tokio::time::timeout(timeout, heartbeat_rx.recv())
352358
.await
353359
.map_err(|_| Error::HeartbeatTimeout)?
354360
.ok_or(Error::HeartbeatTimeout)?;
361+
362+
#[cfg(feature = "tracing")]
363+
tracing::trace!(sid = ?self.id, "pong received");
364+
355365
interval_tick.tick().await;
356366
}
357367
}
@@ -364,7 +374,7 @@ where
364374
.expect("Pong rx should be locked only once");
365375

366376
#[cfg(feature = "tracing")]
367-
tracing::debug!("[sid={}] heartbeat receiver routine started", self.id);
377+
tracing::debug!(sid = ?self.id, "heartbeat receiver routine started");
368378

369379
loop {
370380
tokio::time::timeout(interval + timeout, heartbeat_rx.recv())
@@ -373,7 +383,7 @@ where
373383
.ok_or(Error::HeartbeatTimeout)?;
374384

375385
#[cfg(feature = "tracing")]
376-
tracing::debug!("[sid={}] ping received, sending pong", self.id);
386+
tracing::trace!(sid = ?self.id, "ping received, sending pong");
377387
self.internal_tx
378388
.try_send(smallvec![Packet::Pong])
379389
.map_err(|_| Error::HeartbeatTimeout)?;

crates/socketioxide/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ tower-layer.workspace = true
2626
http.workspace = true
2727
http-body.workspace = true
2828
thiserror.workspace = true
29-
smallvec.workspace = true
3029
hyper.workspace = true
3130
matchit.workspace = true
3231
pin-project-lite.workspace = true

crates/socketioxide/src/extract/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//! that it is dropped at least when the socket is disconnected.
3030
//! Otherwise it will create a memory leak. It is why the [`SocketRef`] extractor is used instead of cloning
3131
//! the socket for common usage.
32-
//! If you want to deserialize the [`Value`] data you must manually call the `Data` extractor to deserialize it.
32+
//! If you want to deserialize the [`Value`](socketioxide_core::Value) data you must manually call the `Data` extractor to deserialize it.
3333
//!
3434
//! [`FromConnectParts`]: crate::handler::FromConnectParts
3535
//! [`FromMessageParts`]: crate::handler::FromMessageParts

crates/socketioxide/src/io.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Default for SocketIoConfig {
8080

8181
/// A builder to create a [`SocketIo`] instance.
8282
/// It contains everything to configure the socket.io server with a [`SocketIoConfig`].
83-
/// It can be used to build either a Tower [`Layer`](tower::layer::Layer) or a [`Service`](tower::Service).
83+
/// It can be used to build either a Tower [`Layer`](tower_layer::Layer) or a [`Service`](tower_service::Service).
8484
pub struct SocketIoBuilder<A: Adapter = LocalAdapter> {
8585
config: SocketIoConfig,
8686
engine_config_builder: EngineIoConfigBuilder,
@@ -291,21 +291,21 @@ impl SocketIo<LocalAdapter> {
291291

292292
/// Creates a new [`SocketIoService`] and a [`SocketIo`] instance with a default config.
293293
/// This service will be a _standalone_ service that return a 404 error for every non-socket.io request.
294-
/// It can be used as a [`Service`](tower::Service) (see hyper example)
294+
/// It can be used as a [`Service`](tower_service::Service) (see hyper example)
295295
#[inline(always)]
296296
pub fn new_svc() -> (SocketIoService<NotFoundService>, SocketIo) {
297297
Self::builder().build_svc()
298298
}
299299

300300
/// Creates a new [`SocketIoService`] and a [`SocketIo`] instance with a default config.
301-
/// It can be used as a [`Service`](tower::Service) with an inner service
301+
/// It can be used as a [`Service`](tower_service::Service) with an inner service
302302
#[inline(always)]
303303
pub fn new_inner_svc<S: Clone>(svc: S) -> (SocketIoService<S>, SocketIo) {
304304
Self::builder().build_with_inner_svc(svc)
305305
}
306306

307307
/// Builds a [`SocketIoLayer`] and a [`SocketIo`] instance with a default config.
308-
/// It can be used as a tower [`Layer`](tower::layer::Layer) (see axum example)
308+
/// It can be used as a tower [`Layer`](tower_layer::Layer) (see axum example)
309309
#[inline(always)]
310310
pub fn new_layer() -> (SocketIoLayer, SocketIo) {
311311
Self::builder().build_layer()

crates/socketioxide/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
nonstandard_style,
3030
missing_docs
3131
)]
32-
//! Socketioxide is a socket.io server implementation that works as a [`tower`] layer/service.
33-
//! It integrates nicely with the rest of the [`tower`]/[`tokio`]/[`hyper`](https://docs.rs/hyper/latest/hyper/) ecosystem.
32+
//! Socketioxide is a socket.io server implementation that works as a tower layer/service.
33+
//! It integrates nicely with the rest of the [`tower`](https://docs.rs/tower/latest/tower/)/[`tokio`]/[`hyper`](https://docs.rs/hyper/latest/hyper/) ecosystem.
3434
//!
3535
//! ## Table of contents
3636
//! * [Features](#features)
@@ -60,7 +60,7 @@
6060
//! * Polling & Websocket transports
6161
//!
6262
//! ## Compatibility
63-
//! Because it works as a tower [`layer`](tower::layer)/[`service`](tower::Service) or an hyper [`service`](hyper::service::Service)
63+
//! Because it works as a tower [`layer`](tower_layer::Layer)/[`service`](tower_service::Service) or an hyper [`service`](hyper::service::Service)
6464
//! you can use it with any http server frameworks that works with tower/hyper:
6565
//! * [Axum](https://docs.rs/axum/latest/axum/)
6666
//! * [Warp](https://docs.rs/warp/latest/warp/) (Not supported with socketioxide >= 0.9.0 as long as warp doesn't migrate to hyper v1)
@@ -105,7 +105,7 @@
105105
//! }
106106
//! ```
107107
//! ## Initialisation
108-
//! The [`SocketIo`] struct is the main entry point of the library. It is used to create a [`Layer`](tower::layer) or a [`Service`](tower::Service).
108+
//! The [`SocketIo`] struct is the main entry point of the library. It is used to create a [`Layer`](tower_layer::Layer) or a [`Service`](tower_service::Service).
109109
//! Later it can be used as the equivalent of the `io` object in the JS API.
110110
//!
111111
//! When creating your [`SocketIo`] instance, you can use the builder pattern to configure it with the [`SocketIoBuilder`] struct.

crates/socketioxide/src/service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! ## A Tower [`Service`](tower::Service) and Hyper [`Service`](hyper::service::Service) for socket.io so it
1+
//! ## A Tower [`Service`](tower_service::Service) and Hyper [`Service`](hyper::service::Service) for socket.io so it
22
//! can be used with frameworks supporting tower and hyper services.
33
//!
44
//! #### Example with a raw `hyper` standalone service (most of the time it easier to use a framework like `axum` or `salvo`):

0 commit comments

Comments
 (0)