Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/riverqueue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.queue("default", QueueConfig::new(10))
.build()?;
// Work jobs until Ctrl-C, then stop fetching and let running jobs finish.
let mut run = client.start_with_graceful_shutdown(async {
let mut run = client.start_with_graceful_stop(async {
let _ = tokio::signal::ctrl_c().await;
})?;

Expand Down
2 changes: 1 addition & 1 deletion rust/riverqueue/src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ impl ClientBuilder {
/// The client starts this timer when fetching stops, however the stop was
/// requested: [`RunHandle::stop`](crate::RunHandle::stop),
/// [`Stopper::stop`](crate::Stopper::stop), or the signal passed to
/// [`Client::start_with_graceful_shutdown`]. Jobs still running when it
/// [`Client::start_with_graceful_stop`]. Jobs still running when it
/// expires are cancelled as if by
/// [`Stopper::stop_and_cancel`](crate::Stopper::stop_and_cancel).
#[must_use]
Expand Down
8 changes: 4 additions & 4 deletions rust/riverqueue/src/client/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Client {
///
/// ```no_run
/// # async fn example(client: riverqueue::Client) -> Result<(), riverqueue::Error> {
/// let mut run = client.start_with_graceful_shutdown(async {
/// let mut run = client.start_with_graceful_stop(async {
/// let _ = tokio::signal::ctrl_c().await;
/// })?;
/// // Returns after Ctrl-C once in-flight jobs have finished.
Expand All @@ -84,7 +84,7 @@ impl Client {
/// # Errors
///
/// Returns the same errors as [`Client::start`].
pub fn start_with_graceful_shutdown<F>(&self, signal: F) -> Result<RunHandle, Error>
pub fn start_with_graceful_stop<F>(&self, signal: F) -> Result<RunHandle, Error>
where
F: std::future::Future<Output = ()> + Send + 'static,
{
Expand Down Expand Up @@ -565,7 +565,7 @@ impl Stopper {
/// handle as they were, apart from any stop the method already requested. To
/// stop the client from another task, obtain a [`Stopper`] with
/// [`RunHandle::stopper`] or start the client with
/// [`Client::start_with_graceful_shutdown`].
/// [`Client::start_with_graceful_stop`].
///
/// The client's result is reported to the first call that observes it
/// stopping; later calls return `Ok(())`.
Expand Down Expand Up @@ -627,7 +627,7 @@ impl RunHandle {
///
/// This relinquishes waiting for the client: it runs until a [`Stopper`]
/// obtained earlier from [`RunHandle::stopper`] or the signal passed to
/// [`Client::start_with_graceful_shutdown`] stops it, an essential service
/// [`Client::start_with_graceful_stop`] stops it, an essential service
/// fails, or the process exits. Nothing observes its result, and jobs
/// running when the process exits are left `running` for the rescuer.
/// Most applications should keep the handle and await
Expand Down
10 changes: 5 additions & 5 deletions rust/riverqueue/tests/lifecycle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Client lifecycle: stopping from other tasks, graceful shutdown signals,
//! Client lifecycle: stopping from other tasks, graceful stop signals,
//! cancel safety, and idempotency.
//!
//! Lifecycle behavior doesn't depend on the backend, so these tests use
Expand Down Expand Up @@ -246,29 +246,29 @@ async fn dropping_the_handle_requests_a_hard_stop() {
}

#[tokio::test(flavor = "multi_thread")]
async fn graceful_shutdown_signal_accepts_a_cancellation_token() {
async fn graceful_stop_signal_accepts_a_cancellation_token() {
let database = TestDatabase::new().await;
let client = database.client(&Gate::new(), 1);
let token = CancellationToken::new();

let mut run = client
.start_with_graceful_shutdown(token.clone().cancelled_owned())
.start_with_graceful_stop(token.clone().cancelled_owned())
.unwrap();
run.wait_ready().await.unwrap();
token.cancel();
wait_stopped(&mut run).await;
}

#[tokio::test(flavor = "multi_thread")]
async fn graceful_shutdown_signal_stops_softly() {
async fn graceful_stop_signal_stops_softly() {
let database = TestDatabase::new().await;
let gate = Gate::new();
let client = database.client(&gate, 1);
let running = insert_gated(&client).await;
let (signal_sender, signal) = oneshot::channel::<()>();

let mut run = client
.start_with_graceful_shutdown(async move {
.start_with_graceful_stop(async move {
let _ = signal.await;
})
.unwrap();
Expand Down
Loading