risedev/task/
postgres_service.rs1use crate::PostgresConfig;
16use crate::task::docker_service::{DockerService, DockerServiceConfig};
17
18impl DockerServiceConfig for PostgresConfig {
19 fn id(&self) -> String {
20 self.id.clone()
21 }
22
23 fn is_user_managed(&self) -> bool {
24 self.user_managed
25 }
26
27 fn image(&self) -> String {
28 self.image.clone()
29 }
30
31 fn args(&self) -> Vec<String> {
32 ["-c", "wal_level=logical", "-c", "max_replication_slots=30"]
34 .map(String::from)
35 .to_vec()
36 }
37
38 fn envs(&self) -> Vec<(String, String)> {
39 vec![
40 ("POSTGRES_HOST_AUTH_METHOD".to_owned(), "trust".to_owned()),
41 ("POSTGRES_USER".to_owned(), self.user.clone()),
42 ("POSTGRES_PASSWORD".to_owned(), self.password.clone()),
43 ("POSTGRES_DB".to_owned(), self.database.clone()),
44 (
45 "POSTGRES_INITDB_ARGS".to_owned(),
46 "--encoding=UTF-8 --lc-collate=C --lc-ctype=C".to_owned(),
47 ),
48 ]
49 }
50
51 fn ports(&self) -> Vec<(String, String)> {
52 vec![(self.port.to_string(), "5432".to_owned())]
53 }
54
55 fn data_path(&self) -> Option<String> {
56 self.persist_data
57 .then(|| "/var/lib/postgresql/data".to_owned())
58 }
59}
60
61pub type PostgresService = DockerService<PostgresConfig>;