MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / Postgres

Class Postgres

misc/python/materialize/mzcompose/services/postgres.py:27–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27class Postgres(Service):
28 def __init__(
29 self,
30 name: str = "postgres",
31 mzbuild: str = "postgres",
32 image: str | None = None,
33 ports: list[str] = ["5432"],
34 extra_command: list[str] = [],
35 environment: list[str] = [
36 "POSTGRESDB=postgres",
37 "POSTGRES_PASSWORD=postgres",
38 "LD_PRELOAD=libeatmydata.so",
39 ],
40 volumes: list[str] = [],
41 max_wal_senders: int = 100,
42 max_replication_slots: int = 100,
43 setup_materialize: bool = False,
44 restart: str = "no",
45 ) -> None:
46 command: list[str] = [
47 "postgres",
48 "-c",
49 "wal_level=logical",
50 "-c",
51 f"max_wal_senders={max_wal_senders}",
52 "-c",
53 f"max_replication_slots={max_replication_slots}",
54 "-c",
55 "max_connections=5000",
56 ] + extra_command
57
58 if setup_materialize:
59 path = os.path.relpath(
60 MZ_ROOT / "misc" / "postgres" / "setup_materialize.sql",
61 loader.composition_path,
62 )
63 volumes = volumes + [
64 f"{path}:/docker-entrypoint-initdb.d/z_setup_materialize.sql"
65 ]
66
67 environment = environment + ["PGPORT=26257"]
68
69 config: ServiceConfig = {"image": image} if image else {"mzbuild": mzbuild}
70
71 config.update(
72 {
73 "command": command,
74 "allow_host_ports": True,
75 "ports": ports,
76 "environment": environment,
77 "healthcheck": {
78 "test": ["CMD", "pg_isready", "-U", "postgres"],
79 "interval": "1s",
80 "start_period": "30s",
81 },
82 "restart": restart,
83 "volumes": volumes,
84 }

Callers 15

mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90
create_postgresFunction · 0.90
mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90
create_postgresFunction · 0.90
mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90
mzcompose.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected