1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Job queueing and processing library with queues stored in Postgres 9.5+
//!
//! # Example
//!
//! ```no_run
//! extern crate dbq;
//! extern crate postgres;
//! extern crate serde_json;
//!
//! use std::error::Error;
//! use std::result::Result;
//! use std::thread;
//! use std::time::Duration;
//!
//! // A simple handler that prints "Hello!" for any job it runs
//! #[derive(Clone)]
//! struct HelloHandler {}
//!
//! fn main() -> Result<(), Box<Error>> {
//! let db_conn_params = "postgres://postgres:password@localhost/db";
//! let conn = postgres::Connection::connect(db_conn_params, postgres::TlsMode::None)?;
//!
//! // Schema config allows for changing the database schema and table names
//! // Defaults are no schema (default is used) and tables are prefixed with "dbq_"
//! let schema_config = dbq::SchemaConfig::default();
//! // Run the migrations on start. Migrations are idempotent and should be run
//! // on startup
//! dbq::run_migrations(&schema_config, &conn, Some(646_271)).unwrap();
//!
//! let queue = dbq::Queue::new(schema_config, "de_lancie_q".to_string());
//!
//! // Enqueue a job
//! queue.enqueue("job_a", serde_json::Value::Null, 3, &conn)?;
//!
//! // Start a worker pool
//! let workers_config =
//! dbq::WorkerPoolConfig::new(queue, db_conn_params, HelloHandler {})?;
//! let workers = dbq::WorkerPool::start(workers_config);
//!
//! // Give a worker time to find and start the job
//! thread::sleep(Duration::new(1, 0));
//! // Shutdown the worker pool waiting for all currently executing jobs to finish
//! workers.join();
//! Ok(())
//! }
//!
//! impl dbq::Handler for HelloHandler {
//! type Error = std::io::Error;
//!
//! fn handle(&self, _ctx: dbq::JobContext) -> Result<(), Self::Error> {
//! println!("Hello!");
//! Ok(())
//! }
//! }
//! ```
extern crate crossbeam_channel;
extern crate log;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;