Back to all reviewers

Follow API conventions

influxdata/influxdb
Based on 6 comments
Rust

Design APIs following modern conventions and best practices to improve usability, maintainability, and consistency across your codebase. APIs should prioritize:

API Rust

Reviewer Prompt

Design APIs following modern conventions and best practices to improve usability, maintainability, and consistency across your codebase. APIs should prioritize:

  1. Use intuitive method naming that clearly expresses purpose and follows a consistent pattern:
// Instead of:
.query_sql("foo").with_query("SELECT * FROM bar")

// Prefer:
.query("foo").with_sql("SELECT * FROM bar")
  1. Reuse existing functionality rather than reimplementing similar features:
// Instead of:
let now = self.time_provider.now().timestamp_nanos();
Some(now - retention_period as i64)

// Prefer:
self.time_provider.now().checked_sub(Duration::nanoseconds(retention_period))
  1. Leverage library conveniences for cleaner API construction:
// Instead of:
let db_query_param = format!("db={}", db.into());
let mut url = self.base_url.join(api_path)?;
url.set_query(Some(&db_query_param));
let mut req = self.http_client.delete(url);

// Prefer:
let mut url = self.base_url.join(api_path)?;
let mut req = self.http_client.delete(url).query(&[("db", db.as_ref())]);
  1. Standardize types across API boundaries to maintain consistency:
// Instead of duplicating types in multiple crates:
// influxdb3_client::Precision and influxdb3_server::Precision

// Consider moving shared types to a common crate or re-exporting
// from a single source to ensure they're always identical
  1. Maintain proper encapsulation - public APIs should hide implementation details and provide only the intended functionality to consumers.
6
Comments Analyzed
Rust
Primary Language
API
Category

Source Discussions