From bd3cc5c17586dd03538a4038c50ef95e2497438e Mon Sep 17 00:00:00 2001 From: geofmureithi Date: Wed, 10 Jul 2024 11:38:54 +0300 Subject: [PATCH 1/2] fix: add missing exposed config --- packages/apalis-sql/src/mysql.rs | 5 +++++ packages/apalis-sql/src/sqlite.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/packages/apalis-sql/src/mysql.rs b/packages/apalis-sql/src/mysql.rs index 7a2be32..b3ae469 100644 --- a/packages/apalis-sql/src/mysql.rs +++ b/packages/apalis-sql/src/mysql.rs @@ -114,6 +114,11 @@ impl MysqlStorage { pub fn codec(&self) -> &BoxCodec { &self.codec } + + /// Get the config used by the storage + pub fn get_config(&self) -> &Config { + &self.config + } } impl MysqlStorage { diff --git a/packages/apalis-sql/src/sqlite.rs b/packages/apalis-sql/src/sqlite.rs index 6a3e25d..751cbf0 100644 --- a/packages/apalis-sql/src/sqlite.rs +++ b/packages/apalis-sql/src/sqlite.rs @@ -149,6 +149,11 @@ impl SqliteStorage { pub fn codec(&self) -> &SqliteCodec { &self.codec } + + /// Get the config used by the storage + pub fn get_config(&self) -> &Config { + &self.config + } } async fn fetch_next( From cfa89c11ac1c1c57ad1221b95a00bdc4697699eb Mon Sep 17 00:00:00 2001 From: geofmureithi Date: Wed, 10 Jul 2024 11:46:12 +0300 Subject: [PATCH 2/2] fix: add getters --- packages/apalis-sql/src/lib.rs | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/packages/apalis-sql/src/lib.rs b/packages/apalis-sql/src/lib.rs index e74c7a5..6ddf5c2 100644 --- a/packages/apalis-sql/src/lib.rs +++ b/packages/apalis-sql/src/lib.rs @@ -56,13 +56,13 @@ impl Default for Config { impl Config { /// Create a new config with a jobs namespace pub fn new(namespace: &str) -> Self { - Config::default().namespace(namespace) + Config::default().set_namespace(namespace) } /// Interval between database poll queries /// /// Defaults to 30ms - pub fn poll_interval(mut self, interval: Duration) -> Self { + pub fn set_poll_interval(mut self, interval: Duration) -> Self { self.poll_interval = interval; self } @@ -70,7 +70,7 @@ impl Config { /// Interval between worker keep-alive database updates /// /// Defaults to 30s - pub fn keep_alive(mut self, keep_alive: Duration) -> Self { + pub fn set_keep_alive(mut self, keep_alive: Duration) -> Self { self.keep_alive = keep_alive; self } @@ -78,7 +78,7 @@ impl Config { /// Buffer size to use when querying for jobs /// /// Defaults to 10 - pub fn buffer_size(mut self, buffer_size: usize) -> Self { + pub fn set_buffer_size(mut self, buffer_size: usize) -> Self { self.buffer_size = buffer_size; self } @@ -86,8 +86,43 @@ impl Config { /// Set the namespace to consume and push jobs to /// /// Defaults to "apalis::sql" - pub fn namespace(mut self, namespace: &str) -> Self { + pub fn set_namespace(mut self, namespace: &str) -> Self { self.namespace = namespace.to_owned(); self } + + /// Gets a reference to the keep_alive duration. + pub fn keep_alive(&self) -> &Duration { + &self.keep_alive + } + + /// Gets a mutable reference to the keep_alive duration. + pub fn keep_alive_mut(&mut self) -> &mut Duration { + &mut self.keep_alive + } + + /// Gets the buffer size. + pub fn buffer_size(&self) -> usize { + self.buffer_size + } + + /// Gets a reference to the poll_interval duration. + pub fn poll_interval(&self) -> &Duration { + &self.poll_interval + } + + /// Gets a mutable reference to the poll_interval duration. + pub fn poll_interval_mut(&mut self) -> &mut Duration { + &mut self.poll_interval + } + + /// Gets a reference to the namespace. + pub fn namespace(&self) -> &String { + &self.namespace + } + + /// Gets a mutable reference to the namespace. + pub fn namespace_mut(&mut self) -> &mut String { + &mut self.namespace + } }