-
Notifications
You must be signed in to change notification settings - Fork 116
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
chore(health): extract health into separate crate #1008
base: main
Are you sure you want to change the base?
Conversation
2685e95
to
c1ed4d3
Compare
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let swagger_crate_folder = Path::new("../../libs/endpoints/health"); |
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.
swagger or health ?
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.
In general, will this work in other than blockscou-rs repositories and will this build inside docker containers?
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.
I believe it is better to leave the proto/health/v1/health.proto
file as it is used by some of other services
.field_attribute( | ||
".blockscout.stats.v1.HealthCheckRequest.service", | ||
"#[serde(default)]" | ||
) |
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.
Lets move that definition into the health endpoint crate
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.
maybe just add optional
to service
field?
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.
need to add to proto then remove
use prost_build::Config; | ||
|
||
pub fn add_to_compile_config(config: &mut Config) { | ||
config.bytes([".grpc.health"]).type_attribute( |
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.
In my opinion it is the client code responsibility to decide should the generated code use bytes or not, so I suggest to remove it from here and only leave .bytes(["."])
in the client code
pub fn add_to_compile_config(config: &mut Config) { | ||
config.bytes([".grpc.health"]).type_attribute( | ||
".grpc.health", | ||
"#[actix_prost_macros::serde(rename_all=\"snake_case\")]", |
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.
Also, wdyt about leaving the case definition as the client responsibility as well?
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let swagger_crate_folder = Path::new("../../libs/endpoints/health"); |
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.
In general, will this work in other than blockscou-rs repositories and will this build inside docker containers?
); | ||
} | ||
|
||
pub fn proto_files(path_to_swagger_crate: &Path) -> Vec<PathBuf> { |
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.
pub fn proto_files(path_to_swagger_crate: &Path) -> Vec<PathBuf> { | |
pub fn proto_files(path_to_health_crate: &Path) -> Vec<PathBuf> { |
need to fix troubles with versioning/path resolution |
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.
Overall, good job 👍👍👍
Extract common logic for setting up health endpoint compilation (+ proto file). This way the implementation details are hidden under the functions and can be reused for other crates.