From 9cff817ed6b422c4e758250ad2027fd3f3ce5bcb Mon Sep 17 00:00:00 2001 From: asonix Date: Fri, 16 Nov 2018 18:14:33 -0600 Subject: [PATCH] Rename crate, update TODO --- Cargo.toml | 2 +- TODO | 70 ++---------------------------------- jobs-actix/Cargo.toml | 2 +- jobs-server-tokio/Cargo.toml | 2 +- jobs-tokio/Cargo.toml | 2 +- 5 files changed, 7 insertions(+), 71 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d309766..e0a82ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jobs" +name = "background-jobs" version = "0.1.0" authors = ["asonix "] edition = "2018" diff --git a/TODO b/TODO index 42b7340..bb54e9e 100644 --- a/TODO +++ b/TODO @@ -2,70 +2,6 @@ Gracefull Shutdown 2. -base port is return port -base port + 1 is port mapping port -base port + 2 is first queue port - -server creates port mapping ON START, and moves jobs started more than 24 hours prior to now into QUEUE from RUNNING - -server supplies an infinite push of port mapping on base_port + 1 -worker gets port mapping from server using pull on base_port + 1 - -QueuePort bucket - key: PortNum - Value: QueueName - - get access: - Cursor iterates over Key/Value pairs - - set access: - Ports are never overwritten, but new ports can be added - - interaction: - base_port: usize, - queues: BTreeSet - - queue_port_bucket = store.bucket(); - - store = store.write_lock(); - - let read_txn = store.read_txn(); - let write_txn = store.write_txn(); - - let queue_map = lock(write_txn, |write_txn| { - let cursor = read_txn.cursor(); - - let (unused_queues, queue_map) = cursor - .iter() - .fold(Ok((queues, BTreeMap::new())), |acc, (port, queue)| { - acc.and_then(|(mut queues, mut bm)| { - port = parse_port(port)?; - queue = parse_queue(queue)?; - - queues.remove(queue); - bm.insert(queue, port); - - Ok((queues, bm)) - }) - })?; - - let start_port = queue_map.iter().max_by(|(_, v)| v).unwrap_or(base_port + 2); - - let (queue_map, _) = unused_queues - .into_iter() - .fold(Ok((queue_map, start_port)), |acc, queue_name| { - acc.and_then(|(mut bm, port_num)| { - write_txn.set(port_num, queue_name)?; - bm.insert(queue_name, port_num); - - Ok((bm, port_num + 1)) - }) - })?; - - Ok(queue_map) - })?; - - write_txn.commit(); - read_txn.commit(); - - Ok(queue_map) +Don't mark pushed jobs as running, mark them as 'staged' +Clear staged jobs that are 10 minutes old +Send a Running notification from the worker to move a job from 'staged' to 'running' diff --git a/jobs-actix/Cargo.toml b/jobs-actix/Cargo.toml index 083191b..28c2fa6 100644 --- a/jobs-actix/Cargo.toml +++ b/jobs-actix/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jobs-actix" +name = "background-jobs-actix" version = "0.1.0" authors = ["asonix "] edition = "2018" diff --git a/jobs-server-tokio/Cargo.toml b/jobs-server-tokio/Cargo.toml index 99b7887..fa7a05d 100644 --- a/jobs-server-tokio/Cargo.toml +++ b/jobs-server-tokio/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jobs-server-tokio" +name = "background-jobs-server-tokio" version = "0.1.0" authors = ["asonix "] edition = "2018" diff --git a/jobs-tokio/Cargo.toml b/jobs-tokio/Cargo.toml index 8ca4f87..a12ca41 100644 --- a/jobs-tokio/Cargo.toml +++ b/jobs-tokio/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jobs-tokio" +name = "background-jobs-tokio" version = "0.1.0" authors = ["asonix "] edition = "2018"