Skip to content

Commit

Permalink
rexport more tokio stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
glendc committed Nov 5, 2023
1 parent 5f37627 commit 6616c45
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions rama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ pub mod state;
pub mod stream;

pub use tokio::main;

pub use tokio::{select, spawn};
2 changes: 1 addition & 1 deletion rama/src/server/tcp/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl<L> TcpListener<L> {

loop {
let guard = guard.clone();
tokio::select! {
crate::select! {
_ = guard.cancelled() => {
tracing::info!("signal received: initiate graceful shutdown");
break Ok(());
Expand Down
2 changes: 1 addition & 1 deletion rama/src/service/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where
}
});
} else {
tokio::spawn(async move {
crate::spawn(async move {
if let Err(err) = service.call(request).await {
let err = err.into();
tracing::error!(error = err, "service error");
Expand Down
2 changes: 1 addition & 1 deletion rama/src/stream/service/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{service::Service, stream::Stream};
/// ```rust
/// use rama::{service::Service, stream::service::EchoService};
///
/// # #[tokio::main]
/// # #[rama::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # let stream = tokio_test::io::Builder::new().read(b"hello world").write(b"hello world").build();
/// let mut service = EchoService::new();
Expand Down
7 changes: 4 additions & 3 deletions rama/src/stream/service/tracker/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ use std::{
task::{Context, Poll},
};

use crate::stream::{AsyncRead, AsyncWrite, ReadBuf};

use pin_project_lite::pin_project;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

pin_project! {
/// A wrapper around a [`AsyncRead`] and/or [`AsyncWrite`] that tracks the number
Expand Down Expand Up @@ -283,7 +284,7 @@ mod tests {
let (check_tx, mut check_rx) = tokio::sync::broadcast::channel(1);
let check_rx_2 = check_tx.subscribe();

let task_1 = tokio::spawn(async move {
let task_1 = crate::spawn(async move {
let mut tracker = tracker;
let mut buf = [0u8; 3];

Expand Down Expand Up @@ -315,7 +316,7 @@ mod tests {
let task_2 = {
let handle = handle.clone();
let mut check_rx = check_rx_2;
tokio::spawn(async move {
crate::spawn(async move {
check_rx.recv().await.unwrap();

assert_eq!(handle.read(), 3);
Expand Down

0 comments on commit 6616c45

Please sign in to comment.