Skip to content

Commit

Permalink
doc: added metadata for docs.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
AH-dark committed Jul 9, 2024
1 parent 899a913 commit 46212cb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ homepage = "https://github.com/AH-dark/distributed-scheduler"
authors = ["AH-dark <[email protected]>"]
readme = "README.md"
license = "AGPL-3.0-or-later"
documentation = "https://docs.rs/distributed-scheduler/latest/"
documentation = "https://docs.rs/distributed-scheduler"
rust-version = "1.71.0"
exclude = [".*"]

[package.metadata.docs.rs]
features = ["full"]
all-features = true

[features]
full = ["driver-redis", "driver-etcd"]
Expand Down
2 changes: 2 additions & 0 deletions src/cron.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tokio::sync::Mutex;
use crate::driver::Driver;
use crate::node_pool;

/// The `Cron` struct is the main entry point for the library, providing the ability to add and remove jobs.
pub struct Cron<'a, D>
where
D: Driver + Send + Sync,
Expand All @@ -23,6 +24,7 @@ pub enum Error {
NodePool(#[from] node_pool::Error),
}

/// Run the scheduler in a separate task, return a Future
async fn run_scheduler<'a>(job_scheduler: Arc<Mutex<job_scheduler::JobScheduler<'a>>>) {
let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(1));

Expand Down
4 changes: 4 additions & 0 deletions src/driver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
mod utils;

#[cfg(feature = "driver-redis")]
/// Driver based on Redis Scan
pub mod redis;

#[cfg(feature = "driver-redis")]
/// Driver based on Redis ZSet
pub mod redis_zset;

#[cfg(feature = "driver-etcd")]
/// Driver based on Etcd
pub mod etcd;

#[async_trait::async_trait]
/// The driver trait, which defines the node list management interface.
pub trait Driver {
/// Get the local node id.
fn node_id(&self) -> String;
Expand Down
2 changes: 2 additions & 0 deletions src/driver/utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pub static GLOBAL_KEY_PREFIX: &str = "distributed-scheduler";

/// Get the key prefix for the given service name.
pub fn get_key_prefix(service_name: &str) -> String {
format!("{}:{}:", GLOBAL_KEY_PREFIX, service_name)
}

#[cfg(feature = "driver-redis")]
/// Get the zset key for the given service name.
pub fn get_zset_key(service_name: &str) -> String {
format!("{}:{}", GLOBAL_KEY_PREFIX, service_name)
}
Expand Down

0 comments on commit 46212cb

Please sign in to comment.