Module materialize.zippy.replica_capabilities

Expand source code Browse git
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

from enum import Enum

from materialize.zippy.framework import Capabilities, Capability


class ReplicaSizeType(Enum):
    Nodes = 1
    Workers = 2
    Both = 3


class ReplicaExists(Capability):
    """A replica exists in the Mz instance."""

    name: str
    size_type: ReplicaSizeType
    size: str

    def __init__(self, name: str) -> None:
        self.name = name


def source_capable_clusters(capabilities: Capabilities) -> list[str]:
    if len(capabilities.get(ReplicaExists)) > 0:
        # Default cluster may have multiple replicas, can not be used for sources
        return ["storage"]
    else:
        return ["storage", "quickstart"]

Functions

def source_capable_clusters(capabilities: Capabilities) ‑> list[str]
Expand source code Browse git
def source_capable_clusters(capabilities: Capabilities) -> list[str]:
    if len(capabilities.get(ReplicaExists)) > 0:
        # Default cluster may have multiple replicas, can not be used for sources
        return ["storage"]
    else:
        return ["storage", "quickstart"]

Classes

class ReplicaExists (name: str)

A replica exists in the Mz instance.

Expand source code Browse git
class ReplicaExists(Capability):
    """A replica exists in the Mz instance."""

    name: str
    size_type: ReplicaSizeType
    size: str

    def __init__(self, name: str) -> None:
        self.name = name

Ancestors

Class variables

var name : str
var size : str
var size_typeReplicaSizeType
class ReplicaSizeType (*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Expand source code Browse git
class ReplicaSizeType(Enum):
    Nodes = 1
    Workers = 2
    Both = 3

Ancestors

  • enum.Enum

Class variables

var Both
var Nodes
var Workers