mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-09 06:22:57 +00:00
This patch started as an effort to support CLI working against remote pageserver, but turned into a pretty big refactoring. * CLI now does not look into repository files directly. New commands 'branch_create' and 'identify_system' were introduced into page_service to support that. * Branch management that was scattered between local_env and zenith/main.rs is moved into pageserver/branches.rs. That code could better fit in Repository/Timeline impl, but I'll leave that for a different patch. * All tests-related code from local_env went into integration_tests/src/lib.rs as an extension to PostgresNode trait. * Paths-generating functions were concentrated around corresponding config types (LocalEnv and PageserverConf).
33 lines
1.1 KiB
Rust
33 lines
1.1 KiB
Rust
//! This module acts as a switchboard to access different repositories managed by this
|
|
//! page server. Currently, a Page Server can only manage one repository, so there
|
|
//! isn't much here. If we implement multi-tenancy, this will probably be changed into
|
|
//! a hash map, keyed by the tenant ID.
|
|
|
|
use crate::repository::rocksdb::RocksRepository;
|
|
use crate::repository::Repository;
|
|
use crate::walredo::PostgresRedoManager;
|
|
use crate::PageServerConf;
|
|
use lazy_static::lazy_static;
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
lazy_static! {
|
|
pub static ref REPOSITORY: Mutex<Option<Arc<dyn Repository + Send + Sync>>> = Mutex::new(None);
|
|
}
|
|
|
|
pub fn init(conf: &PageServerConf) {
|
|
let mut m = REPOSITORY.lock().unwrap();
|
|
|
|
// Set up a WAL redo manager, for applying WAL records.
|
|
let walredo_mgr = PostgresRedoManager::new(conf);
|
|
|
|
// we have already changed current dir to the repository.
|
|
let repo = RocksRepository::new(conf, Arc::new(walredo_mgr));
|
|
|
|
*m = Some(Arc::new(repo));
|
|
}
|
|
|
|
pub fn get_repository() -> Arc<dyn Repository + Send + Sync> {
|
|
let o = &REPOSITORY.lock().unwrap();
|
|
Arc::clone(o.as_ref().unwrap())
|
|
}
|