-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #932 from ods/merge-kafka-python
Merge kafka-python
- Loading branch information
Showing
110 changed files
with
13,657 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .client import AIOKafkaAdminClient | ||
from .new_partitions import NewPartitions | ||
from .new_topic import NewTopic | ||
|
||
__all__ = ["AIOKafkaAdminClient", "NewPartitions", "NewTopic"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from enum import IntEnum | ||
|
||
|
||
class ConfigResourceType(IntEnum): | ||
"""An enumerated type of config resources""" | ||
|
||
BROKER = 4, | ||
TOPIC = 2 | ||
|
||
|
||
class ConfigResource: | ||
"""A class for specifying config resources. | ||
Arguments: | ||
resource_type (ConfigResourceType): the type of kafka resource | ||
name (string): The name of the kafka resource | ||
configs ({key : value}): A maps of config keys to values. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
resource_type, | ||
name, | ||
configs=None | ||
): | ||
if not isinstance(resource_type, (ConfigResourceType)): | ||
resource_type = ConfigResourceType[str(resource_type).upper()] | ||
self.resource_type = resource_type | ||
self.name = name | ||
self.configs = configs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class NewPartitions: | ||
"""A class for new partition creation on existing topics. Note that the | ||
length of new_assignments, if specified, must be the difference between the | ||
new total number of partitions and the existing number of partitions. | ||
Arguments: | ||
total_count (int): | ||
the total number of partitions that should exist on the topic | ||
new_assignments ([[int]]): | ||
an array of arrays of replica assignments for new partitions. | ||
If not set, broker assigns replicas per an internal algorithm. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
total_count, | ||
new_assignments=None | ||
): | ||
self.total_count = total_count | ||
self.new_assignments = new_assignments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from aiokafka.errors import IllegalArgumentError | ||
|
||
|
||
class NewTopic: | ||
""" A class for new topic creation | ||
Arguments: | ||
name (string): name of the topic | ||
num_partitions (int): number of partitions | ||
or -1 if replica_assignment has been specified | ||
replication_factor (int): replication factor or -1 if | ||
replica assignment is specified | ||
replica_assignment (dict of int: [int]): A mapping containing | ||
partition id and replicas to assign to it. | ||
topic_configs (dict of str: str): A mapping of config key | ||
and value for the topic. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
name, | ||
num_partitions, | ||
replication_factor, | ||
replica_assignments=None, | ||
topic_configs=None, | ||
): | ||
if not ( | ||
(num_partitions == -1 or replication_factor == -1) | ||
^ (replica_assignments is None) | ||
): | ||
raise IllegalArgumentError( | ||
"either num_partitions/replication_factor or replica_assignment " | ||
"must be specified" | ||
) | ||
self.name = name | ||
self.num_partitions = num_partitions | ||
self.replication_factor = replication_factor | ||
self.replica_assignments = replica_assignments or {} | ||
self.topic_configs = topic_configs or {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.