Skip to content

Commit

Permalink
Migrate to Rust 2024 edition
Browse files Browse the repository at this point in the history
Changes made are purely due to formatting changes in rustfmt 2024
  • Loading branch information
FlixCoder committed Feb 20, 2025
1 parent 93cd778 commit 080f287
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Flix <[email protected]>"]
categories = ["asynchronous", "concurrency", "database"]
description = "Message/job queue based on bonsaidb, similar to sqlxmq."
documentation = "https://docs.rs/bonsaimq"
edition = "2021"
edition = "2024"
homepage = "https://github.com/FlixCoder/bonsaimq"
keywords = ["message", "job", "queue", "database", "persistent"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions examples/checkpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
mod common;

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::Result;

/// Example job function using checkpoints.
Expand Down
6 changes: 3 additions & 3 deletions examples/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
mod common;

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use color_eyre::{eyre::eyre, Result};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::{Result, eyre::eyre};

/// Example job function using context. It receives a handle to the current job,
/// which gives the ability to get the context.
Expand Down
8 changes: 4 additions & 4 deletions examples/error_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
mod common;

use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
atomic::{AtomicBool, Ordering},
};

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use color_eyre::{eyre::bail, Result};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::{Result, eyre::bail};

/// Example job function that returns an error.
async fn greet(mut job: CurrentJob) -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
mod common;

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::Result;

/// Example job function. It receives a handle to the current job, which gives
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
edition = "2021"
edition = "2024"
hard_tabs = true
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::num::TryFromIntError;

use bonsaidb::core::{pubsub, Error as BonsaiError};
use bonsaidb::core::{Error as BonsaiError, pubsub};
use thiserror::Error;

/// This crate's main error type.
Expand Down
8 changes: 4 additions & 4 deletions src/job.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//! Provider for job handlers.
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
};

use serde::{de::DeserializeOwned, Serialize};
use serde::{Serialize, de::DeserializeOwned};
use tokio::task::JoinHandle;
use tokio_retry::{strategy::FixedInterval, RetryIf};
use tokio_retry::{RetryIf, strategy::FixedInterval};
use tracing_futures::Instrument;

use crate::{queue::Id, runner::JobRunnerHandle, AbortOnDropHandle, Error, JobFunctionType};
use crate::{AbortOnDropHandle, Error, JobFunctionType, queue::Id, runner::JobRunnerHandle};

/// Handle to the `JobRunner`.
type JobRunnerHandler = Arc<dyn JobRunnerHandle + Send + Sync>;
Expand Down
8 changes: 2 additions & 6 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::time::Duration;
use bonsaidb::core::{
document::{CollectionDocument, Emit},
schema::{
view::{map::Mappings, ViewUpdatePolicy},
Collection, CollectionMapReduce, ReduceResult, Schema, View, ViewMapResult,
ViewMappedValue, ViewSchema,
view::{ViewUpdatePolicy, map::Mappings},
},
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -178,11 +178,7 @@ impl RetryTiming {
let duration =
initial.saturating_mul(2_u32.saturating_pow(executions.saturating_sub(1)));

if let Some(max) = maximum {
duration.min(max)
} else {
duration
}
if let Some(max) = maximum { duration.min(max) } else { duration }
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::{error::Error, future::Future, pin::Pin};

use crate::{spawn::JobBuilder, CurrentJob};
use crate::{CurrentJob, spawn::JobBuilder};

/// Function type of the jobs returned by the job registry.
pub type JobFunctionType = Box<
Expand Down
8 changes: 4 additions & 4 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ use std::{
fmt::Debug,
ops::Range,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
atomic::{AtomicUsize, Ordering},
},
thread::available_parallelism,
time::Duration,
};

use bonsaidb::core::{
Error as BonsaiError,
async_trait::async_trait,
connection::AsyncConnection,
document::CollectionDocument,
pubsub::{AsyncPubSub, AsyncSubscriber},
schema::{view::map::MappedDocuments, Collection, SerializedCollection},
schema::{Collection, SerializedCollection, view::map::MappedDocuments},
transaction::{Operation, Transaction},
Error as BonsaiError,
};
use time::OffsetDateTime;

use crate::{
queue::{DueMessages, Id, Message, MessagePayload, Timestamp, MQ_NOTIFY},
AbortOnDropHandle, CurrentJob, Error, JobRegister,
queue::{DueMessages, Id, MQ_NOTIFY, Message, MessagePayload, Timestamp},
};

/// Error handler dynamic function type.
Expand Down
4 changes: 2 additions & 2 deletions src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use serde::Serialize;
use time::OffsetDateTime;

use crate::{
Error,
queue::{
generate_id, Id, LatestMessage, Message, MessagePayload, RetryTiming, Timestamp, MQ_NOTIFY,
Id, LatestMessage, MQ_NOTIFY, Message, MessagePayload, RetryTiming, Timestamp, generate_id,
},
Error,
};

/// Builder for spawning a job. By default, `ordered` mode is off and infinite
Expand Down
2 changes: 1 addition & 1 deletion src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::time::Duration;
use bonsaidb::core::{connection::AsyncConnection, schema::SerializedCollection};

use crate::{
queue::{Id, Message},
Error,
queue::{Id, Message},
};

/// Check whether the job with the given ID exists. Can also be used to check if
Expand Down
4 changes: 2 additions & 2 deletions tests/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::{
};

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::Result;

/// Counter
Expand Down
4 changes: 2 additions & 2 deletions tests/ordering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ mod common;
use std::sync::atomic::{AtomicUsize, Ordering};

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::Result;

/// Counter
Expand Down
4 changes: 2 additions & 2 deletions tests/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use std::{
};

use bonsaidb::local::{
config::{Builder, StorageConfiguration},
AsyncDatabase,
config::{Builder, StorageConfiguration},
};
use bonsaimq::{job_registry, CurrentJob, JobRegister, JobRunner, MessageQueueSchema};
use bonsaimq::{CurrentJob, JobRegister, JobRunner, MessageQueueSchema, job_registry};
use color_eyre::Result;

/// Counter
Expand Down

0 comments on commit 080f287

Please sign in to comment.