mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-19 14:10:37 +00:00
small refactor
This commit is contained in:
@@ -71,13 +71,13 @@ fn main() -> Result<()> {
|
||||
let pgbin = matches.get_one::<String>("pgbin").unwrap_or(&pgbin_default);
|
||||
|
||||
let remote_ext_config = matches.get_one::<String>("remote-ext-config");
|
||||
let remote_storage = match remote_ext_config {
|
||||
let ext_remote_storage = match remote_ext_config {
|
||||
Some(x) => Some(init_remote_storage(x)?),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let rt = Runtime::new().unwrap();
|
||||
let copy_remote_storage = remote_storage.clone();
|
||||
let copy_remote_storage = ext_remote_storage.clone();
|
||||
rt.block_on(async move {
|
||||
download_extension(©_remote_storage, ExtensionType::Shared, pgbin)
|
||||
.await
|
||||
@@ -198,7 +198,7 @@ fn main() -> Result<()> {
|
||||
live_config_allowed,
|
||||
state: Mutex::new(new_state),
|
||||
state_changed: Condvar::new(),
|
||||
remote_storage,
|
||||
ext_remote_storage,
|
||||
};
|
||||
let compute = Arc::new(compute_node);
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ pub struct ComputeNode {
|
||||
pub state: Mutex<ComputeState>,
|
||||
/// `Condvar` to allow notifying waiters about state changes.
|
||||
pub state_changed: Condvar,
|
||||
/// S3 extensions configuration variables (JSON)
|
||||
pub remote_storage: Option<GenericRemoteStorage>,
|
||||
/// S3 extensions configuration variables
|
||||
pub ext_remote_storage: Option<GenericRemoteStorage>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
||||
@@ -135,7 +135,7 @@ async fn routes(req: Request<Body>, compute: &Arc<ComputeNode>) -> Response<Body
|
||||
);
|
||||
|
||||
match extension_server::download_extension(
|
||||
&compute.remote_storage,
|
||||
&compute.ext_remote_storage,
|
||||
ExtensionType::Shared,
|
||||
&compute.pgbin,
|
||||
)
|
||||
@@ -160,59 +160,6 @@ async fn routes(req: Request<Body>, compute: &Arc<ComputeNode>) -> Response<Body
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: delete this function
|
||||
// // debug only
|
||||
// async fn download_file(filename: &str) -> anyhow::Result<()> {
|
||||
// info!("requested file {}", filename);
|
||||
|
||||
// let from_prefix: &str = "/tmp"; //debug only
|
||||
// let to_prefix = "/home/anastasia/work/neon/pg_install/v15/";
|
||||
|
||||
// if filename.ends_with(".so") {
|
||||
// info!("requested file is a shared object file {}", filename);
|
||||
|
||||
// let from_path = Path::new(from_prefix).join("lib").join(filename);
|
||||
// let to_path = Path::new(to_prefix).join("lib/postgresql/").join(filename);
|
||||
|
||||
// info!(
|
||||
// "copying file {} from {} to {}",
|
||||
// filename,
|
||||
// from_path.display(),
|
||||
// to_path.display()
|
||||
// );
|
||||
|
||||
// fs::copy(from_path, to_path)?;
|
||||
// } else {
|
||||
// info!("requested all extension files with prefix {}", filename);
|
||||
|
||||
// let from_path = Path::new(from_prefix).join("share/extension/");
|
||||
// let to_path = Path::new(to_prefix).join("share/postgresql/extension/");
|
||||
|
||||
// info!(
|
||||
// "copying files from {} to {}",
|
||||
// from_path.display(),
|
||||
// to_path.display()
|
||||
// );
|
||||
|
||||
// for file in fs::read_dir(from_path.clone()).unwrap().flatten() {
|
||||
// let fname = file.file_name().into_string().unwrap();
|
||||
|
||||
// if fname.starts_with(filename) && fname.ends_with(".sql") {
|
||||
// info!(
|
||||
// "copying file {} from {} to {}",
|
||||
// fname,
|
||||
// from_path.display(),
|
||||
// to_path.display()
|
||||
// );
|
||||
|
||||
// fs::copy(file.path(), to_path.join(fname))?;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
async fn handle_configure_request(
|
||||
req: Request<Body>,
|
||||
compute: &Arc<ComputeNode>,
|
||||
|
||||
@@ -493,7 +493,6 @@ impl Endpoint {
|
||||
|
||||
// Launch compute_ctl
|
||||
println!("Starting postgres node at '{}'", self.connstr());
|
||||
|
||||
let mut cmd = Command::new(self.env.neon_distrib_dir.join("compute_ctl"));
|
||||
cmd.args(["--http-port", &self.http_address.port().to_string()])
|
||||
.args(["--pgdata", self.pgdata().to_str().unwrap()])
|
||||
|
||||
@@ -87,3 +87,7 @@ relocatable = true
|
||||
all_extensions = [x[0] for x in cur.fetchall()]
|
||||
log.info(all_extensions)
|
||||
assert "test_ext" in all_extensions
|
||||
|
||||
# TODO: we shouldn't need these...
|
||||
endpoint.stop()
|
||||
env.pageserver.http_client().tenant_detach(tenant)
|
||||
|
||||
Reference in New Issue
Block a user