yugabyte.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.mzcompose.service import (
  10. Service,
  11. ServiceConfig,
  12. )
  13. YUGABYTE_VERSION = "2.23.0.0-b710"
  14. class Yugabyte(Service):
  15. def __init__(
  16. self,
  17. name: str = "yugabyte",
  18. version: str = YUGABYTE_VERSION,
  19. image: str | None = None,
  20. ports: list[int] | None = None,
  21. ) -> None:
  22. if image is None:
  23. image = f"yugabytedb/yugabyte:{version}"
  24. if ports is None:
  25. ports = [5433]
  26. command_list = [
  27. "bin/yugabyted",
  28. "start",
  29. "--background=false",
  30. "--master_flags",
  31. ",".join(
  32. [
  33. "ysql_yb_enable_replication_commands=true",
  34. "ysql_cdc_active_replication_slot_window_ms=0",
  35. "allowed_preview_flags_csv={ysql_yb_enable_replication_commands}",
  36. ]
  37. ),
  38. "--tserver_flags",
  39. "ysql_pg_conf=wal_level=logical",
  40. ]
  41. config: ServiceConfig = {
  42. "image": image,
  43. "ports": ports,
  44. "command": command_list,
  45. "healthcheck": {
  46. "test": [
  47. "CMD",
  48. "bash",
  49. "-c",
  50. '/home/yugabyte/bin/ysqlsh -h $(hostname) -p 5433 -U yugabyte -c "\\conninfo"',
  51. ],
  52. "interval": "1s",
  53. "start_period": "30s",
  54. },
  55. }
  56. super().__init__(name=name, config=config)