Skip to content

Commit

Permalink
fix: add getters
Browse files Browse the repository at this point in the history
  • Loading branch information
geofmureithi committed Jul 10, 2024
1 parent bd3cc5c commit cfa89c1
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions packages/apalis-sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,73 @@ 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
}

/// 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
}

/// 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
}

/// 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
}
}

0 comments on commit cfa89c1

Please sign in to comment.