Skip to content

Commit

Permalink
chore(lib): remove panic on add
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Dec 27, 2023
1 parent f7d589b commit 4d6f279
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "async_job"
version = "0.1.1"
version = "0.1.3"
edition = "2021"
description = "Simple async cron job crate for Rust"
repository = "https://github.com/spider-rs/async_job"
Expand All @@ -9,14 +9,15 @@ keywords = ["crawler", "spider"]
categories = ["web-programming"]
license = "MIT"
documentation = "https://docs.rs/async_job"
authors = ["j-mendez <jeff@a11ywatch.com>"]

[dependencies]
async-trait = "0.1.74"
async-trait = "0.1.75"
chrono = "0.4.31"
cron = "0.12.0"
lazy_static = "1.4.0"
log = "0.4.20"
tokio = { version = "^1.34.0", features = [ "macros", "time", "parking_lot" ] }
tokio = { version = "^1.35.0", features = [ "macros", "time", "parking_lot" ] }

[features]
default = ["rt-multi-thread"]
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ use chrono::{DateTime, Duration, Utc};
pub use cron::Schedule;
use lazy_static::lazy_static;
use log::{debug, error, info};
use std::panic;
use std::sync::mpsc::{Receiver, Sender};
use std::sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -213,13 +212,12 @@ impl Runner {

/// Add jobs into the runner
///
/// **panics** if you try to push a job onto already started runner
/// Does nothing if already running.
#[allow(clippy::should_implement_trait)]
pub fn add(mut self, job: Box<dyn Job>) -> Self {
if self.running {
panic!("Cannot push job onto runner once the runner is started!");
if !self.running {
self.jobs.push(job);
}
self.jobs.push(job);
self
}

Expand Down

0 comments on commit 4d6f279

Please sign in to comment.