source_capabilities.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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.zippy.kafka_capabilities import TopicExists
  10. from materialize.zippy.watermarked_object_capabilities import WatermarkedObjectExists
  11. from materialize.zippy.watermarks import Watermarks
  12. class SourceExists(WatermarkedObjectExists):
  13. """A Kafka source exists in Materialize."""
  14. @classmethod
  15. def format_str(cls) -> str:
  16. return "source_{}"
  17. def __init__(
  18. self, name: str, topic: TopicExists, cluster_name: str, uses_ssh_tunnel: bool
  19. ) -> None:
  20. self.name = name
  21. self.topic = topic
  22. self.cluster_name = cluster_name
  23. self.uses_ssh_tunnel = uses_ssh_tunnel
  24. def get_watermarks(self) -> Watermarks:
  25. return self.topic.watermarks
  26. def get_name_for_query(self) -> str:
  27. return f"{self.name}_tbl"