zookeeper.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 import (
  10. DEFAULT_CONFLUENT_PLATFORM_VERSION,
  11. )
  12. from materialize.mzcompose.service import Service, ServiceConfig
  13. class Zookeeper(Service):
  14. def __init__(
  15. self,
  16. name: str = "zookeeper",
  17. image: str = "confluentinc/cp-zookeeper",
  18. tag: str = DEFAULT_CONFLUENT_PLATFORM_VERSION,
  19. port: int = 2181,
  20. volumes: list[str] = [],
  21. environment: list[str] = ["ZOOKEEPER_CLIENT_PORT=2181"],
  22. platform: str | None = None,
  23. ) -> None:
  24. config: ServiceConfig = {
  25. "image": f"{image}:{tag}",
  26. "ports": [port],
  27. "volumes": volumes,
  28. "environment": environment,
  29. "healthcheck": {
  30. "test": ["CMD", "nc", "-z", "localhost", "2181"],
  31. "interval": "1s",
  32. "start_period": "120s",
  33. },
  34. }
  35. if platform:
  36. config["platform"] = platform
  37. super().__init__(
  38. name=name,
  39. config=config,
  40. )