kafka_capabilities.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 enum import Enum
  10. from materialize.zippy.framework import Capability
  11. from materialize.zippy.watermarks import Watermarks
  12. class KafkaRunning(Capability):
  13. """Kafka is running in the environment."""
  14. pass
  15. class Envelope(Enum):
  16. """Kafka envelope to be used for a particular topic or source.
  17. If the Envelope is NONE, no deletions take place on the topic, just insertions
  18. """
  19. NONE = 1
  20. UPSERT = 2
  21. class TopicExists(Capability):
  22. """A Topic exists on the Kafka instance."""
  23. @classmethod
  24. def format_str(cls) -> str:
  25. return "topic-{}"
  26. def __init__(self, name: str, partitions: int, envelope: Envelope) -> None:
  27. self.name = name
  28. self.partitions = partitions
  29. self.envelope = envelope
  30. self.watermarks = Watermarks()
  31. def get_watermarks(self) -> Watermarks:
  32. return self.watermarks