-
-
Notifications
You must be signed in to change notification settings - Fork 137
visibility updates #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
visibility updates #1325
Conversation
WalkthroughThe visibility of several structs and struct fields was updated from private to public in two modules. Specifically, the Changes
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/prism/home/mod.rs (1)
64-68
: Consider encapsulation implications of making fields public.While making these
HomeResponse
fields public enables external access to response data, it breaks encapsulation by allowing direct field modification. Consider whether accessor methods might be more appropriate for maintaining data integrity.If direct field access is intentional for serialization/deserialization purposes, this change is acceptable. However, if data integrity is a concern, consider implementing getter methods instead:
#[derive(Debug, Serialize)] pub struct HomeResponse { - pub alerts_info: AlertsInfo, - pub stats_details: Vec<DatedStats>, - pub datasets: Vec<DataSet>, + alerts_info: AlertsInfo, + stats_details: Vec<DatedStats>, + datasets: Vec<DataSet>, } + +impl HomeResponse { + pub fn alerts_info(&self) -> &AlertsInfo { + &self.alerts_info + } + + pub fn stats_details(&self) -> &[DatedStats] { + &self.stats_details + } + + pub fn datasets(&self) -> &[DataSet] { + &self.datasets + } +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/handlers/http/llm.rs
(1 hunks)src/prism/home/mod.rs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: Build Default x86_64-pc-windows-msvc
- GitHub Check: Build Default aarch64-apple-darwin
- GitHub Check: Build Default x86_64-apple-darwin
- GitHub Check: Build Default aarch64-unknown-linux-gnu
- GitHub Check: Build Kafka aarch64-apple-darwin
- GitHub Check: Build Default x86_64-unknown-linux-gnu
- GitHub Check: Quest Smoke and Load Tests for Distributed deployments
- GitHub Check: coverage
- GitHub Check: Build Kafka x86_64-unknown-linux-gnu
- GitHub Check: Quest Smoke and Load Tests for Standalone deployments
🔇 Additional comments (2)
src/prism/home/mod.rs (2)
43-48
: LGTM: DatedStats visibility change is appropriate.Making
DatedStats
public is reasonable as it contains statistical data that external consumers may need to access. The fields represent standard metrics data without sensitive information.
58-61
: LGTM: DataSet visibility change enables external integration.The
DataSet
struct contains dataset metadata that's appropriate for public API exposure, enabling external systems to work with dataset information.
// Temperory type | ||
#[derive(Debug, serde::Serialize)] | ||
struct Field { | ||
pub struct Field { | ||
name: String, | ||
data_type: String, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Consider the implications of making a temporary type public.
While making the Field
struct public enables external usage, the comment indicates this is a "Temporary type." Making temporary types part of the public API can create maintenance burden and potential breaking changes when the type is eventually replaced or removed.
Please verify this design decision and consider:
- Whether this struct should remain temporary or become a stable part of the API
- If temporary, consider using internal visibility or adding clear deprecation timelines
🏁 Script executed:
#!/bin/bash
# Description: Check if Field struct is used outside this module and verify API usage patterns.
# Check for external usage of Field struct
rg -A 3 -B 3 "Field" --type rust
# Check for imports of this struct from other modules
rg "use.*llm.*Field" --type rust
Length of output: 43338
Re-evaluate the visibility of the temporary Field
type in src/handlers/http/llm.rs
The Field
struct is only consumed within this module (no imports of llm::Field
elsewhere), yet it’s marked pub
despite its “Temporary type” label. To avoid accidental use and keep your module’s API surface minimal:
• Remove the pub
modifier so it stays private to llm.rs
• Or, if you really intend for this to become a stable HTTP/JSON DTO, update its comment to reflect permanence and add versioning/deprecation guidance
Suggested diff:
// Temperory type
#[derive(Debug, serde::Serialize)]
-pub struct Field {
+ struct Field {
name: String,
data_type: String,
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Temperory type | |
#[derive(Debug, serde::Serialize)] | |
struct Field { | |
pub struct Field { | |
name: String, | |
data_type: String, | |
} | |
// Temperory type | |
#[derive(Debug, serde::Serialize)] | |
struct Field { | |
name: String, | |
data_type: String, | |
} |
🤖 Prompt for AI Agents
In src/handlers/http/llm.rs around lines 52 to 57, the Field struct is marked
public despite being a temporary type and only used internally. To minimize the
public API surface and avoid accidental external use, remove the pub modifier
from the Field struct to keep it private to the module. If the struct is
intended to become a stable API type, update the comment to reflect its
permanence and include versioning or deprecation guidance instead.
Fixes #XXXX.
Description
This PR has:
Summary by CodeRabbit