faust.assignor.client_assignment

Client Assignment.

class faust.assignor.client_assignment.CopartitionedAssignment(actives: Optional[Set[int]] = None, standbys: Optional[Set[int]] = None, topics: Optional[Set[str]] = None)[source]

Copartitioned Assignment.

actives: Set[int]
standbys: Set[int]
topics: Set[str]
validate() None[source]
Return type:

None

num_assigned(active: bool) int[source]
Return type:

int

get_unassigned(num_partitions: int, active: bool) Set[int][source]
Return type:

_GenericAlias[int]

pop_partition(active: bool) int[source]
Return type:

int

unassign_partition(partition: int, active: bool) None[source]
Return type:

None

assign_partition(partition: int, active: bool) None[source]
Return type:

None

unassign_extras(capacity: int, replicas: int) None[source]
Return type:

None

partition_assigned(partition: int, active: bool) bool[source]
Return type:

bool

promote_standby_to_active(standby_partition: int) None[source]
Return type:

None

get_assigned_partitions(active: bool) Set[int][source]
Return type:

_GenericAlias[int]

can_assign(partition: int, active: bool) bool[source]
Return type:

bool

class faust.assignor.client_assignment.ClientAssignment(actives, standbys, *, __strict__=True, __faust=None, **kwargs)[source]

Client Assignment data model.

actives: MutableMapping[str, List[int]]

Describes a field.

Used for every field in Record so that they can be used in join’s /group_by etc.

Examples

>>> class Withdrawal(Record):
...    account_id: str
...    amount: float = 0.0
>>> Withdrawal.account_id
<FieldDescriptor: Withdrawal.account_id: str>
>>> Withdrawal.amount
<FieldDescriptor: Withdrawal.amount: float = 0.0>
Parameters:
  • field (str) – Name of field.

  • type (Type) – Field value type.

  • required (bool) – Set to false if field is optional.

  • default (Any) – Default value when required=False.

Keyword Arguments:
  • model (Type) – Model class the field belongs to.

  • parent (FieldDescriptorT) – parent field if any.

standbys: MutableMapping[str, List[int]]

Describes a field.

Used for every field in Record so that they can be used in join’s /group_by etc.

Examples

>>> class Withdrawal(Record):
...    account_id: str
...    amount: float = 0.0
>>> Withdrawal.account_id
<FieldDescriptor: Withdrawal.account_id: str>
>>> Withdrawal.amount
<FieldDescriptor: Withdrawal.amount: float = 0.0>
Parameters:
  • field (str) – Name of field.

  • type (Type) – Field value type.

  • required (bool) – Set to false if field is optional.

  • default (Any) – Default value when required=False.

Keyword Arguments:
  • model (Type) – Model class the field belongs to.

  • parent (FieldDescriptorT) – parent field if any.

property active_tps: Set[TP]
Return type:

_GenericAlias[TP]

property standby_tps: Set[TP]
Return type:

_GenericAlias[TP]

kafka_protocol_assignment(table_manager: TableManagerT) Sequence[Tuple[str, List[int]]][source]
Return type:

_GenericAlias[_GenericAlias[str, _GenericAlias[int]]]

add_copartitioned_assignment(assignment: CopartitionedAssignment) None[source]
Return type:

None

copartitioned_assignment(topics: Set[str]) CopartitionedAssignment[source]
Return type:

CopartitionedAssignment

asdict()

Convert record to Python dictionary.

class faust.assignor.client_assignment.ClientMetadata(assignment, url, changelog_distribution, external_topic_distribution=None, topic_groups=None, *, __strict__=True, __faust=None, **kwargs)[source]

Client Metadata data model.

assignment: ClientAssignment

Describes a field.

Used for every field in Record so that they can be used in join’s /group_by etc.

Examples

>>> class Withdrawal(Record):
...    account_id: str
...    amount: float = 0.0
>>> Withdrawal.account_id
<FieldDescriptor: Withdrawal.account_id: str>
>>> Withdrawal.amount
<FieldDescriptor: Withdrawal.amount: float = 0.0>
Parameters:
  • field (str) – Name of field.

  • type (Type) – Field value type.

  • required (bool) – Set to false if field is optional.

  • default (Any) – Default value when required=False.

Keyword Arguments:
  • model (Type) – Model class the field belongs to.

  • parent (FieldDescriptorT) – parent field if any.

url: str
changelog_distribution: MutableMapping[str, MutableMapping[str, List[int]]]

Describes a field.

Used for every field in Record so that they can be used in join’s /group_by etc.

Examples

>>> class Withdrawal(Record):
...    account_id: str
...    amount: float = 0.0
>>> Withdrawal.account_id
<FieldDescriptor: Withdrawal.account_id: str>
>>> Withdrawal.amount
<FieldDescriptor: Withdrawal.amount: float = 0.0>
Parameters:
  • field (str) – Name of field.

  • type (Type) – Field value type.

  • required (bool) – Set to false if field is optional.

  • default (Any) – Default value when required=False.

Keyword Arguments:
  • model (Type) – Model class the field belongs to.

  • parent (FieldDescriptorT) – parent field if any.

asdict()

Convert record to Python dictionary.

external_topic_distribution: MutableMapping[str, MutableMapping[str, List[int]]]

Describes a field.

Used for every field in Record so that they can be used in join’s /group_by etc.

Examples

>>> class Withdrawal(Record):
...    account_id: str
...    amount: float = 0.0
>>> Withdrawal.account_id
<FieldDescriptor: Withdrawal.account_id: str>
>>> Withdrawal.amount
<FieldDescriptor: Withdrawal.amount: float = 0.0>
Parameters:
  • field (str) – Name of field.

  • type (Type) – Field value type.

  • required (bool) – Set to false if field is optional.

  • default (Any) – Default value when required=False.

Keyword Arguments:
  • model (Type) – Model class the field belongs to.

  • parent (FieldDescriptorT) – parent field if any.

topic_groups: Mapping[str, int]

Describes a field.

Used for every field in Record so that they can be used in join’s /group_by etc.

Examples

>>> class Withdrawal(Record):
...    account_id: str
...    amount: float = 0.0
>>> Withdrawal.account_id
<FieldDescriptor: Withdrawal.account_id: str>
>>> Withdrawal.amount
<FieldDescriptor: Withdrawal.amount: float = 0.0>
Parameters:
  • field (str) – Name of field.

  • type (Type) – Field value type.

  • required (bool) – Set to false if field is optional.

  • default (Any) – Default value when required=False.

Keyword Arguments:
  • model (Type) – Model class the field belongs to.

  • parent (FieldDescriptorT) – parent field if any.