Run 'cargo fmt'.

Fixes a few formatting discrepancies had crept in recently.
This commit is contained in:
Heikki Linnakangas
2021-07-14 20:00:40 +01:00
parent ad92b66eed
commit befefe8d84
8 changed files with 43 additions and 26 deletions

View File

@@ -297,9 +297,7 @@ impl PostgresNode {
"shared_preload_libraries = zenith \n\ "shared_preload_libraries = zenith \n\
zenith.page_server_connstring = 'host={} port={}'\n\ zenith.page_server_connstring = 'host={} port={}'\n\
zenith.zenith_timeline='{}'\n", zenith.zenith_timeline='{}'\n",
host, host, port, self.timelineid
port,
self.timelineid
), ),
)?; )?;

View File

@@ -1,5 +1,5 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::net::{TcpStream}; use std::net::TcpStream;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
use std::thread; use std::thread;
@@ -12,8 +12,8 @@ use postgres::{Config, NoTls};
use crate::local_env::LocalEnv; use crate::local_env::LocalEnv;
use crate::read_pidfile; use crate::read_pidfile;
use zenith_utils::connstring::connection_address;
use pageserver::branches::BranchInfo; use pageserver::branches::BranchInfo;
use zenith_utils::connstring::connection_address;
// //
// Control routines for pageserver. // Control routines for pageserver.
@@ -36,7 +36,9 @@ impl PageServerNode {
} }
fn default_config() -> Config { fn default_config() -> Config {
"postgresql://no_user@localhost:64000/no_db".parse().unwrap() "postgresql://no_user@localhost:64000/no_db"
.parse()
.unwrap()
} }
pub fn connection_config(&self) -> Config { pub fn connection_config(&self) -> Config {

View File

@@ -642,7 +642,12 @@ impl ObjectTimeline {
return Ok(page_img); return Ok(page_img);
} }
static ZERO_PAGE: [u8; 8192] = [0u8; 8192]; static ZERO_PAGE: [u8; 8192] = [0u8; 8192];
trace!("page {} blk {} at {} not found", tag.rel, tag.blknum, req_lsn); trace!(
"page {} blk {} at {} not found",
tag.rel,
tag.blknum,
req_lsn
);
Ok(Bytes::from_static(&ZERO_PAGE)) Ok(Bytes::from_static(&ZERO_PAGE))
/* return Err("could not find page image")?; */ /* return Err("could not find page image")?; */
} }

View File

@@ -479,7 +479,7 @@ mod tests {
// Create another relation // Create another relation
let buftag2 = BufferTag { let buftag2 = BufferTag {
rel: TESTREL_B, rel: TESTREL_B,
blknum : 0, blknum: 0,
}; };
tline.put_page_image(buftag2, Lsn(2), TEST_IMG("foobar blk 0 at 2"))?; tline.put_page_image(buftag2, Lsn(2), TEST_IMG("foobar blk 0 at 2"))?;
@@ -509,10 +509,7 @@ mod tests {
TEST_IMG("foobar blk 0 at 2") TEST_IMG("foobar blk 0 at 2")
); );
assert_eq!( assert_eq!(newtline.get_rel_size(TESTREL_B, Lsn(4))?, 1);
newtline.get_rel_size(TESTREL_B, Lsn(4))?,
1
);
Ok(()) Ok(())
} }

View File

@@ -6,7 +6,6 @@ use anyhow::{bail, Result};
use log::*; use log::*;
use postgres::{Client, Config, NoTls}; use postgres::{Client, Config, NoTls};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zenith_utils::connstring::connection_host_port;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::fs::{self, File, OpenOptions}; use std::fs::{self, File, OpenOptions};
use std::io::{BufReader, Read, Seek, SeekFrom, Write}; use std::io::{BufReader, Read, Seek, SeekFrom, Write};
@@ -16,6 +15,7 @@ use std::sync::Arc;
use std::thread; use std::thread;
use std::thread::sleep; use std::thread::sleep;
use zenith_utils::bin_ser::LeSer; use zenith_utils::bin_ser::LeSer;
use zenith_utils::connstring::connection_host_port;
use zenith_utils::lsn::Lsn; use zenith_utils::lsn::Lsn;
use crate::replication::HotStandbyFeedback; use crate::replication::HotStandbyFeedback;
@@ -159,10 +159,7 @@ fn request_callback(conf: WalAcceptorConf, timelineid: ZTimelineId) {
let (host, port) = connection_host_port(&me_conf); let (host, port) = connection_host_port(&me_conf);
let callme = format!( let callme = format!(
"callmemaybe {} host={} port={} options='-c ztimelineid={}'", "callmemaybe {} host={} port={} options='-c ztimelineid={}'",
timelineid, timelineid, host, port, timelineid
host,
port,
timelineid
); );
loop { loop {
info!( info!(

View File

@@ -1,8 +1,16 @@
use postgres::Config; use postgres::Config;
pub fn connection_host_port(config: &Config) -> (String, u16) { pub fn connection_host_port(config: &Config) -> (String, u16) {
assert_eq!(config.get_hosts().len(), 1, "only one pair of host and port is supported in connection string"); assert_eq!(
assert_eq!(config.get_ports().len(), 1, "only one pair of host and port is supported in connection string"); config.get_hosts().len(),
1,
"only one pair of host and port is supported in connection string"
);
assert_eq!(
config.get_ports().len(),
1,
"only one pair of host and port is supported in connection string"
);
let host = match &config.get_hosts()[0] { let host = match &config.get_hosts()[0] {
postgres::config::Host::Tcp(host) => host.as_ref(), postgres::config::Host::Tcp(host) => host.as_ref(),
postgres::config::Host::Unix(host) => host.to_str().unwrap(), postgres::config::Host::Unix(host) => host.to_str().unwrap(),
@@ -21,14 +29,24 @@ mod tests {
#[test] #[test]
fn test_connection_host_port() { fn test_connection_host_port() {
let config: Config = "postgresql://no_user@localhost:64000/no_db".parse().unwrap(); let config: Config = "postgresql://no_user@localhost:64000/no_db"
assert_eq!(connection_host_port(&config), ("localhost".to_owned(), 64000)); .parse()
.unwrap();
assert_eq!(
connection_host_port(&config),
("localhost".to_owned(), 64000)
);
} }
#[test] #[test]
#[should_panic(expected = "only one pair of host and port is supported in connection string")] #[should_panic(expected = "only one pair of host and port is supported in connection string")]
fn test_connection_host_port_multiple_ports() { fn test_connection_host_port_multiple_ports() {
let config: Config = "postgresql://no_user@localhost:64000,localhost:64001/no_db".parse().unwrap(); let config: Config = "postgresql://no_user@localhost:64000,localhost:64001/no_db"
assert_eq!(connection_host_port(&config), ("localhost".to_owned(), 64000)); .parse()
.unwrap();
assert_eq!(
connection_host_port(&config),
("localhost".to_owned(), 64000)
);
} }
} }