replica_capabilities.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 Capabilities, Capability
  11. class ReplicaSizeType(Enum):
  12. Nodes = 1
  13. Workers = 2
  14. Both = 3
  15. class ReplicaExists(Capability):
  16. """A replica exists in the Mz instance."""
  17. name: str
  18. size_type: ReplicaSizeType
  19. size: str
  20. def __init__(self, name: str) -> None:
  21. self.name = name
  22. def source_capable_clusters(capabilities: Capabilities) -> list[str]:
  23. if len(capabilities.get(ReplicaExists)) > 0:
  24. # Default cluster may have multiple replicas, can not be used for sources
  25. return ["storage"]
  26. else:
  27. return ["storage", "quickstart"]