pub mod queue_name;
pub mod visibility_timeout_offset;
pub use queue_name::QueueName;
pub use visibility_timeout_offset::VisibilityTimeoutOffset;
use chrono::{DateTime, Utc};
use serde_derive::Deserialize;
use std::time::Duration;
pub const VT_DEFAULT: i32 = 30;
pub const READ_LIMIT_DEFAULT: i32 = 1;
pub const POLL_TIMEOUT_DEFAULT: Duration = Duration::from_secs(5);
pub const POLL_INTERVAL_DEFAULT: Duration = Duration::from_millis(250);
pub const QUEUE_PREFIX: &str = r#"q"#;
pub const ARCHIVE_PREFIX: &str = r#"a"#;
pub const PGMQ_SCHEMA: &str = "pgmq";
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[non_exhaustive]
pub struct PGMQueueMeta {
pub queue_name: String,
pub is_partitioned: bool,
pub is_unlogged: bool,
pub created_at: DateTime<Utc>,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[non_exhaustive]
pub struct Message<T = serde_json::Value, H = serde_json::Value> {
pub msg_id: i64,
pub read_ct: i32,
pub enqueued_at: DateTime<Utc>,
pub last_read_at: Option<DateTime<Utc>>,
pub vt: DateTime<Utc>,
#[cfg_attr(feature = "sqlx", sqlx(json))]
pub message: T,
#[cfg_attr(feature = "sqlx", sqlx(json(nullable)))]
pub headers: Option<H>,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[non_exhaustive]
pub struct SendBatchTopicRow {
pub queue_name: String,
pub msg_id: i64,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[non_exhaustive]
pub struct ListTopicBindingsRow {
pub pattern: String,
pub queue_name: String,
pub bound_at: DateTime<Utc>,
pub compiled_regex: String,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[non_exhaustive]
pub struct ListNotifyInsertThrottlesRow {
pub queue_name: String,
pub throttle_interval_ms: i32,
pub last_notified_at: DateTime<Utc>,
}
#[derive(Clone, Debug, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
#[non_exhaustive]
pub struct QueueMetrics {
pub queue_name: String,
pub queue_length: i64,
pub newest_msg_age_sec: Option<i32>,
pub oldest_msg_age_sec: Option<i32>,
pub total_messages: i64,
pub scrape_time: DateTime<Utc>,
pub queue_visible_length: i64,
}