Skip to content

Conversation

dentiny
Copy link
Owner

@dentiny dentiny commented Aug 17, 2025

Summary

Briefly explain what this PR does.

Related Issues

Closes # or links to related issues.

Changes

Checklist

  • Code builds correctly
  • Tests have been added or updated
  • Documentation updated if necessary
  • I have reviewed my own changes

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @dentiny, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly updates the rest_api_demo.rs example. The primary change involves reconfiguring the demo to interact with an external IP address instead of a local one. Furthermore, the demo's purpose has been altered from showcasing various API functionalities to performing a large-scale data ingestion test, inserting 10 million records into a newly specified table. This change suggests a move towards stress testing or performance evaluation of the data ingestion capabilities.

Highlights

  • Updated API Endpoint: The base_url used for API calls in the demo script has been changed from http://localhost:3030 to http://54.245.134.191:3030, directing the demo to an external endpoint.
  • Refactored Table Creation Parameters: The demo now targets a specific database (pg_mooncake) and table (public.test_table) for creation and data ingestion, moving away from generic placeholders.
  • Shifted Demo Focus to Load Testing: The core functionality of the demo has shifted from demonstrating various API operations (like single inserts, RPC reads, and error handling) to performing a large-scale data ingestion, inserting 10 million records. This indicates a change in focus towards performance or load testing.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the REST API demo. However, it introduces a hardcoded public IP address, which makes the example less portable. More critically, it replaces the comprehensive API demonstration with a massive and slow load test, removing valuable examples of different API functionalities and proper service shutdown. I've provided suggestions to revert these changes to make the demo useful and maintainable again.

Comment on lines +98 to +131
for idx in 0..=10000000 {
println!("\n📝 Inserting data into 'public.test_table'...");
let insert_payload = json!({
"operation": "insert",
"data": {
"id": idx,
"name": format!("name-{}", idx),
"email": format!("name-{}@example.com", idx),
"age": idx,
}
});

let response = client
.post(format!("{base_url}/ingest/public.test_table"))
.header("content-type", "application/json")
.json(&insert_payload)
.send()
.await?;

if response.status().is_success() {
println!("✅ Data inserted successfully!");
let ingest_data: serde_json::Value = response.json().await?;
println!(
" Response: {}",
serde_json::to_string_pretty(&ingest_data)?
);
} else {
println!("❌ Data insertion failed: {}", response.status());
let error_text = response.text().await?;
println!(" Error: {error_text}");
}
});

let response = client
.post(format!("{base_url}/ingest/nonexistent_table"))
.header("content-type", "application/json")
.json(&payload)
.send()
.await?;

if response.status().is_success() {
println!("✅ Request accepted (table will be created dynamically or queued)");
let data: serde_json::Value = response.json().await?;
println!(" Response: {}", serde_json::to_string_pretty(&data)?);
} else {
println!("✅ Expected behavior - non-existent table handling");
let error_data: serde_json::Value = response.json().await?;
println!(
" Response: {}",
serde_json::to_string_pretty(&error_data)?
);
}

// Test 7: Test invalid operation
println!("\n🚫 Testing invalid operation...");
let invalid_payload = json!({
"operation": "invalid_operation",
"data": {"id": 1}
});

let response = client
.post(format!("{base_url}/ingest/demo_users"))
.header("content-type", "application/json")
.json(&invalid_payload)
.send()
.await?;

if response.status().is_client_error() {
println!("✅ Expected error for invalid operation!");
let error_data: serde_json::Value = response.json().await?;
println!(" Error: {}", serde_json::to_string_pretty(&error_data)?);
} else {
println!("❌ Unexpected response: {}", response.status());
}

println!("\n🎉 Demo completed successfully!");
println!("🛑 Shutting down service...");

// Shutdown the service
service_handle.abort();

println!("\n📚 API Endpoints:");
println!(" Health Check: GET {base_url}/health");
println!(" Create Table: POST {base_url}/tables/{{table_name}}");
println!(" Ingest Data: POST {base_url}/ingest/{{table_name}}");
println!("\n📋 Example Usage:");
println!(
"
Create Table:
POST {base_url}/tables/my_table
{{
\"schema\": \"test_schema\",
\"table_id\": \"test_table\",
\"schema\": [
{{\"name\": \"id\", \"data_type\": \"int32\", \"nullable\": false}},
{{\"name\": \"name\", \"data_type\": \"string\", \"nullable\": true}}
]
}}
Insert Data:
POST {base_url}/ingest/my_table
{{
\"operation\": \"insert\",
\"data\": {{
\"id\": 123,
\"name\": \"Example Record\"
}}
}}"
);
tokio::time::sleep(std::time::Duration::from_secs(300)).await;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This change replaces a comprehensive API demonstration with a massive load test. This is not suitable for an example file for several reasons:

  • Unusability as a demo: The loop to insert 10 million records will take an extremely long time to run, making the example impractical for developers trying to understand the API.
  • Loss of functionality demonstration: The previous code demonstrated various important API features, such as reading data back, handling errors for non-existent tables, and testing invalid operations. All of this valuable demonstration code has been removed.
  • Removed graceful shutdown: The graceful shutdown of the service via service_handle.abort() has been removed, which is a regression.
  • Dead code: The read_table_via_rpc function is no longer called, becoming dead code.

An example should be a concise, quick-to-run showcase of the API's features. Load tests are important but should be located in a separate benchmark or test suite (e.g., in a benches directory), not in the examples directory.

I recommend reverting this part of the change to restore the original, more useful example.


let client = reqwest::Client::new();
let base_url = "http://localhost:3030";
let base_url = "http://54.245.134.191:3030";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Hardcoding a public IP address in an example file is not recommended. It makes the demo dependent on an external service that might not be available, and it's not portable for other developers running this example. It's better to use localhost to allow running the service and demo locally. If connecting to a remote service is required, this should be configurable, for example, through an environment variable.

Suggested change
let base_url = "http://54.245.134.191:3030";
let base_url = "http://localhost:3030";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant