diff --git a/aiokafka/client.py b/aiokafka/client.py index 4eea5259..2ec75ec9 100644 --- a/aiokafka/client.py +++ b/aiokafka/client.py @@ -3,6 +3,7 @@ import logging import random import time +from enum import IntEnum import aiokafka.errors as Errors from aiokafka import __version__ @@ -40,12 +41,12 @@ log = logging.getLogger("aiokafka") -class ConnectionGroup: +class ConnectionGroup(IntEnum): DEFAULT = 0 COORDINATION = 1 -class CoordinationType: +class CoordinationType(IntEnum): GROUP = 0 TRANSACTION = 1 diff --git a/aiokafka/conn.py b/aiokafka/conn.py index 333f9fad..d3e5ac98 100644 --- a/aiokafka/conn.py +++ b/aiokafka/conn.py @@ -15,6 +15,7 @@ import uuid import warnings import weakref +from enum import IntEnum import async_timeout @@ -45,7 +46,7 @@ SASL_QOP_AUTH = 1 -class CloseReason: +class CloseReason(IntEnum): CONNECTION_BROKEN = 0 CONNECTION_TIMEOUT = 1 OUT_OF_SYNC = 2 diff --git a/aiokafka/metrics/stats/percentiles.py b/aiokafka/metrics/stats/percentiles.py index e5b99fcb..3c4244c5 100644 --- a/aiokafka/metrics/stats/percentiles.py +++ b/aiokafka/metrics/stats/percentiles.py @@ -1,3 +1,5 @@ +from enum import IntEnum + from aiokafka.metrics.compound_stat import AbstractCompoundStat, NamedMeasurable from aiokafka.metrics.measurable import AnonMeasurable @@ -5,7 +7,7 @@ from .sampled_stat import AbstractSampledStat -class BucketSizing: +class BucketSizing(IntEnum): CONSTANT = 0 LINEAR = 1 diff --git a/aiokafka/producer/transaction_manager.py b/aiokafka/producer/transaction_manager.py index 9e0cfa5c..3f42cdb7 100644 --- a/aiokafka/producer/transaction_manager.py +++ b/aiokafka/producer/transaction_manager.py @@ -1,5 +1,5 @@ from collections import defaultdict, deque, namedtuple -from enum import Enum +from enum import Enum, IntEnum from aiokafka.structs import TopicPartition from aiokafka.util import create_future @@ -16,7 +16,7 @@ class SubscriptionType(Enum): USER_ASSIGNED = 4 -class TransactionResult: +class TransactionResult(IntEnum): ABORT = 0 COMMIT = 1