mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 01:12:56 +00:00
1.66 release speeds up compile times for over 10% according to tests.
Also its Clippy finds plenty of old nits in our code:
* useless conversion, `foo as u8` where `foo: u8` and similar, removed
`as u8` and similar
* useless references and dereferenced (that were automatically adjusted
by the compiler), removed various `&` and `*`
* bool -> u8 conversion via `if/else`, changed to `u8::from`
* Map `.iter()` calls where only values were used, changed to
`.values()` instead
Standing out lints:
* `Eq` is missing in our protoc generated structs. Silenced, does not
seem crucial for us.
* `fn default` looks like the one from `Default` trait, so I've
implemented that instead and replaced the `dummy_*` method in tests with
`::default()` invocation
* Clippy detected that
```
if retry_attempt < u32::MAX {
retry_attempt += 1;
}
```
is a saturating add and proposed to replace it.
49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
use anyhow::Context;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use crate::{background_process, local_env};
|
|
|
|
pub fn start_broker_process(env: &local_env::LocalEnv) -> anyhow::Result<()> {
|
|
let broker = &env.broker;
|
|
let listen_addr = &broker.listen_addr;
|
|
|
|
print!("Starting neon broker at {}", listen_addr);
|
|
|
|
let args = [format!("--listen-addr={listen_addr}")];
|
|
|
|
let client = reqwest::blocking::Client::new();
|
|
background_process::start_process(
|
|
"storage_broker",
|
|
&env.base_data_dir,
|
|
&env.storage_broker_bin(),
|
|
args,
|
|
[],
|
|
background_process::InitialPidFile::Create(&storage_broker_pid_file_path(env)),
|
|
|| {
|
|
let url = broker.client_url();
|
|
let status_url = url.join("status").with_context(|| {
|
|
format!("Failed to append /status path to broker endpoint {url}",)
|
|
})?;
|
|
let request = client
|
|
.get(status_url)
|
|
.build()
|
|
.with_context(|| format!("Failed to construct request to broker endpoint {url}"))?;
|
|
match client.execute(request) {
|
|
Ok(resp) => Ok(resp.status().is_success()),
|
|
Err(_) => Ok(false),
|
|
}
|
|
},
|
|
)
|
|
.context("Failed to spawn storage_broker subprocess")?;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn stop_broker_process(env: &local_env::LocalEnv) -> anyhow::Result<()> {
|
|
background_process::stop_process(true, "storage_broker", &storage_broker_pid_file_path(env))
|
|
}
|
|
|
|
fn storage_broker_pid_file_path(env: &local_env::LocalEnv) -> PathBuf {
|
|
env.base_data_dir.join("storage_broker.pid")
|
|
}
|