use std::sync::Arc;
use graphile_worker_database::{Database, Schema};
use graphile_worker_lifecycle_hooks::HookRegistry;
use graphile_worker_queries::task_identifiers::SharedTaskDetails;
#[derive(Clone)]
pub struct WorkerUtils {
pub(super) database: Database,
pub(super) schema: Schema,
pub(super) hooks: Option<Arc<HookRegistry>>,
pub(super) task_details: SharedTaskDetails,
pub(super) use_local_time: bool,
}
impl WorkerUtils {
pub fn new(database: impl Into<Database>, schema: impl Into<Schema>) -> Self {
Self {
database: database.into(),
schema: schema.into(),
hooks: None,
task_details: SharedTaskDetails::default(),
use_local_time: false,
}
}
pub fn with_hooks(mut self, hooks: Arc<HookRegistry>) -> Self {
self.hooks = Some(hooks);
self
}
pub fn with_task_details(mut self, task_details: SharedTaskDetails) -> Self {
self.task_details = task_details;
self
}
pub fn with_use_local_time(mut self, use_local_time: bool) -> Self {
self.use_local_time = use_local_time;
self
}
}