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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! Queue jobs with Rust and PostgreSQL like a boss.
//!
//! Inspired by, compatible with and partially ported from [`pg-boss`](https://github.com/timgit/pg-boss/tree/master) Node.js package.
//!
//! Heavily influenced by decisions and approaches in [`faktory-rs`](https://github.com/jonhoo/faktory-rs) crate.
//!
//! ```no_run
//! # tokio_test::block_on(async {
//! use std::time::Duration;
//! use serde_json::json;
//! use pgboss::{Client, Job, JobState, Queue};
//!
//! // Create a client first.
//! let c = Client::builder()
//! .schema("desired_schema_name")
//! .connect()
//! .await
//! .unwrap();
//!
//! // Then create a dlq (optional) and a queue.
//! c.create_standard_queue("image_processing_dlq").await.unwrap();
//!
//! // NB! queue should be created before pushing jobs
//! let queue = Queue::builder()
//! .name("image_processing")
//! .dead_letter("qname_dlq")
//! .partition(true)
//! .build();
//! c.create_queue(&queue).await.unwrap();
//!
//! // Build a job and ...
//! let job = Job::builder()
//! .queue_name("image_processing") // which queue this job should be sent to
//! .data(json!({"image_url": "https://..."})) // arbitrary json, your job's payload
//! .priority(10) // will be consumer prior to those with lower priorities
//! .retry_limit(1) // only retry this job once
//! .retry_delay(Duration::from_secs(60 * 5)) // do not retry immediately after failure
//! .expire_in(Duration::from_secs(60 * 5)) // only give the worker 5 minutes to complete the job
//! .retain_for(Duration::from_secs(60 * 60 * 24)) // do not archive for at least 1 day
//! .delay_for(Duration::from_secs(5)) // make it visible to consumers after 5 seconds
//! .singleton_for(Duration::from_secs(7)) // only allow one job for at least 7 seconds
//! .singleton_key("buzz") // allow more than one job if their key is different from this
//! .build();
//!
//! // ... enqueue it.
//! let _id = c.send_job(&job).await.expect("no error");
//!
//! // Consume from the queue.
//! let fetched_job = c
//! .fetch_job("image_processing")
//! .await
//! .expect("fetch w/on errors")
//! .expect("some job");
//!
//! assert_eq!(fetched_job.data, job.data);
//! assert_eq!(fetched_job.state, JobState::Active);
//!
//! c
//! .complete_job(
//! "image_processing",
//! fetched_job.id,
//! json!({"result": "success"})
//! )
//! .await
//! .unwrap();
//! # });
//! ```
//!
pub use ;
pub use Error;
pub use ;
pub use ;
use ;
use FromRow;
use Debug;
pub use JobOptions;
pub const MINIMUM_SUPPORTED_PGBOSS_APP_VERSION: u8 = 26;
pub const CURRENT_PGBOSS_APP_VERSION: u8 = 26;
pub