m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.9 KiB

6 months ago
  1. """ Other useful structs """
  2. from __future__ import absolute_import
  3. from collections import namedtuple
  4. """A topic and partition tuple
  5. Keyword Arguments:
  6. topic (str): A topic name
  7. partition (int): A partition id
  8. """
  9. TopicPartition = namedtuple("TopicPartition",
  10. ["topic", "partition"])
  11. """A Kafka broker metadata used by admin tools.
  12. Keyword Arguments:
  13. nodeID (int): The Kafka broker id.
  14. host (str): The Kafka broker hostname.
  15. port (int): The Kafka broker port.
  16. rack (str): The rack of the broker, which is used to in rack aware
  17. partition assignment for fault tolerance.
  18. Examples: `RACK1`, `us-east-1d`. Default: None
  19. """
  20. BrokerMetadata = namedtuple("BrokerMetadata",
  21. ["nodeId", "host", "port", "rack"])
  22. """A topic partition metadata describing the state in the MetadataResponse.
  23. Keyword Arguments:
  24. topic (str): The topic name of the partition this metadata relates to.
  25. partition (int): The id of the partition this metadata relates to.
  26. leader (int): The id of the broker that is the leader for the partition.
  27. replicas (List[int]): The ids of all brokers that contain replicas of the
  28. partition.
  29. isr (List[int]): The ids of all brokers that contain in-sync replicas of
  30. the partition.
  31. error (KafkaError): A KafkaError object associated with the request for
  32. this partition metadata.
  33. """
  34. PartitionMetadata = namedtuple("PartitionMetadata",
  35. ["topic", "partition", "leader", "replicas", "isr", "error"])
  36. """The Kafka offset commit API
  37. The Kafka offset commit API allows users to provide additional metadata
  38. (in the form of a string) when an offset is committed. This can be useful
  39. (for example) to store information about which node made the commit,
  40. what time the commit was made, etc.
  41. Keyword Arguments:
  42. offset (int): The offset to be committed
  43. metadata (str): Non-null metadata
  44. """
  45. OffsetAndMetadata = namedtuple("OffsetAndMetadata",
  46. # TODO add leaderEpoch: OffsetAndMetadata(offset, leaderEpoch, metadata)
  47. ["offset", "metadata"])
  48. """An offset and timestamp tuple
  49. Keyword Arguments:
  50. offset (int): An offset
  51. timestamp (int): The timestamp associated to the offset
  52. """
  53. OffsetAndTimestamp = namedtuple("OffsetAndTimestamp",
  54. ["offset", "timestamp"])
  55. MemberInformation = namedtuple("MemberInformation",
  56. ["member_id", "client_id", "client_host", "member_metadata", "member_assignment"])
  57. GroupInformation = namedtuple("GroupInformation",
  58. ["error_code", "group", "state", "protocol_type", "protocol", "members", "authorized_operations"])
  59. """Define retry policy for async producer
  60. Keyword Arguments:
  61. Limit (int): Number of retries. limit >= 0, 0 means no retries
  62. backoff_ms (int): Milliseconds to backoff.
  63. retry_on_timeouts:
  64. """
  65. RetryOptions = namedtuple("RetryOptions",
  66. ["limit", "backoff_ms", "retry_on_timeouts"])