-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat: add write
and query
CLI sub-commands
#24671
Conversation
A new crate, influxdb3_client, was added, which provides the Client struct. This gives programmatic access to the infludxb3 HTTP API. This commit implements a partial version of the api_v3_write_lp method along with a test for ensuring the happy path. The underlying API is not yet complete, so the response handling is still a TODO.
The new Client and types related to the Client::api_v3_write_lp method have been documented The stub for the write_lp_from_file test was removed, to be done later
The api_v3_query_sql method was added to the influxdb3 Client, which allows caller to compose a request to the respective API. Similar to the write_lp API, this uses a builder approach to composing the request. The handling of the response was kept naive and just gives back the bytes returned. We may improve this in future once the format handling in the API is nailed down and we have JSON lines supported.
Switched reqwest to use rustls and disabled default features in mockito
Clean up some rustdoc comments and TODO comments Rename the with_auth_header method to with_auth_token to distinguish setting the token itself vs. the entire header; and rename the struct field on Client accordingly Indent the write_lp payload in the test code Remove the reqwest::Client as a parameter to the Client new method
Adds two new sub-commands to the influxdb3 CLI: - query: perform queries against the running server - write: perform writes against the running server Both share a common set of parameters for connecting to the database which are managed in influxdb3/src/commands/common.rs. Currently, query supports all underlying output formats, and can write the output to a file on disk. It only supports SQL as the query language, but will eventually also support InfluxQL. Write supports line protocol for input and expects the source of data to be from a 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.
We should get #24665 merged in first, but this looks good to me and I saw the loom where you demonstrate it. Should make testing things out a bit easier. I'll give it the green check once that is in and this PR has merged in those changes.
eprintln!("Serve command failed: {e}"); | ||
std::process::exit(ReturnCode::Failure as _) | ||
} | ||
} | ||
Some(Command::Query(config)) => { | ||
if let Err(e) = commands::query::command(config).await { | ||
eprintln!("Query command failed: {e}"); |
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.
Tangential to this, but not for this PR, but I feel like we should invest some time in the output of these errors or just the regular command output to look really nice. Possibly something like miette would be good. This is beyond the scope of this PR though. I should probably just open an issue for this.
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.
Opened #24673
@mgattozzi - I pulled down |
This builds on #24665 and is meant to close #24651
Two new sub-commands are added to the
influxdb3
CLI:query
: for performing queries against the running serverwrite
: for performing writes to the running serverThe generated help documentation summarizes each below.
query
write