quickwit/quickwit-codegen/README.md
Describe your service in a proto file.
Define an error and a result type for your service. The error type must implement quickwit_proto::error::GrpcServiceError and have at least the three following variants: Internal, Timeout, and Unavailable.
Add the following dependencies to your project:
[dependencies]
async-trait = { workspace = true }
bytes = { workspace = true }
bytesize = { workspace = true }
http = { workspace = true }
hyper = { workspace = true }
prost = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tonic = { workspace = true }
tower = { workspace = true }
utoipa = { workspace = true }
quickwit-actors = { workspace = true }
quickwit-proto = { workspace = true }
[dev-dependencies]
mockall = { workspace = true }
[build-dependencies]
quickwit-codegen = { workspace = true }
use quickwit_codegen::Codegen;
fn main() {
Codegen::builder()
.with_protos(&["src/hello.proto"])
.with_output_dir("src/")
.with_result_type_path("crate::HelloResult")
.with_error_type_path("crate::HelloError")
.run()
.unwrap();
}
use quickwit_codegen::Codegen;
fn main() {
let mut config = prost_build::Config::default();
config.bytes(["PingRequest.name", "PingResponse.name"]);
Codegen::builder()
.with_protos(&["src/hello.proto"])
.with_output_dir("src/codegen/")
.with_result_type_path("crate::HelloResult")
.with_error_type_path("crate::HelloError")
.with_prost_config(config)
.run()
.unwrap();
}
Checkout the complete working example in the quickwit-codegen-example crate.