Skip to content

Commit

Permalink
feat: added retention policy for v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
stegaBOB committed Jan 19, 2024
1 parent a7a56df commit 417df99
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions influxdb/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ impl Client {
self
}

/// Add a retention policy to [`Client`](crate::Client)
///
/// This is designed for InfluxDB 2.x's backward-compatible API, which
/// maps databases and retention policies to buckets using the **database
/// and retention policy (DBRP) mapping service**.
/// See [InfluxDB Docs](https://docs.influxdata.com/influxdb/v2/reference/api/influxdb-1x/dbrp/) for more details.
#[must_use = "Creating a client is pointless unless you use it"]
pub fn with_retention_policy<S>(mut self, retention_policy: S) -> Self
where
S: Into<String>,
{
let mut with_retention_policy = self.parameters.as_ref().clone();
with_retention_policy.insert("rp", retention_policy.into());
self.parameters = Arc::new(with_retention_policy);
self
}

/// Returns the name of the database the client is using
pub fn database_name(&self) -> &str {
// safe to unwrap: we always set the database name in `Self::new`
Expand Down

0 comments on commit 417df99

Please sign in to comment.