-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added a delete records api #1710
Changes from 43 commits
863a1e8
93fc6c3
7336986
4417733
f7952b6
6293a56
b4a1f08
900540e
49ced95
5e67ea3
684efd8
f0626ff
60b8feb
654e069
86ae277
5afe007
d7f37db
5e4cd7d
50443bc
bd64ea6
fddaa6a
58ac04c
9ba4168
8f7f2a6
9f3152d
e176626
fb202c8
766aa16
e240e2f
cd5cfac
e46e3d6
1366b2d
8ed70cb
dc1e05c
8483b12
293a050
fba0f7b
cdd3ae4
e3b5b96
9f5dcde
227cb0f
e359c0f
d93162a
d965435
8172ca8
60a4258
65b3417
3f1a7f3
e1f484d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
emasab marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -534,6 +534,17 @@ def _check_list_offsets_request(topic_partition_offsets, kwargs): | |||||||||
if not isinstance(kwargs['isolation_level'], _IsolationLevel): | ||||||||||
raise TypeError("isolation_level argument should be an IsolationLevel") | ||||||||||
|
||||||||||
@staticmethod | ||||||||||
def _check_delete_records(request): | ||||||||||
if not isinstance(request, list): | ||||||||||
raise TypeError(f"Expected Request to be a list, got '{type(request).__name__}' ") | ||||||||||
for req in request: | ||||||||||
if not isinstance(req, _TopicPartition): | ||||||||||
raise TypeError("Element of the request list must be of type 'TopicPartition'" + | ||||||||||
f" got '{type(req).__name__}' ") | ||||||||||
if req.partition < 0: | ||||||||||
raise ValueError("'partition' cannot be negative") | ||||||||||
|
||||||||||
pranavrth marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
def create_topics(self, new_topics, **kwargs): | ||||||||||
""" | ||||||||||
Create one or more new topics. | ||||||||||
|
@@ -543,7 +554,8 @@ def create_topics(self, new_topics, **kwargs): | |||||||||
:param float operation_timeout: The operation timeout in seconds, | ||||||||||
controlling how long the CreateTopics request will block | ||||||||||
on the broker waiting for the topic creation to propagate | ||||||||||
in the cluster. A value of 0 returns immediately. Default: 0 | ||||||||||
in the cluster. A value of 0 returns immediately. | ||||||||||
Default: `socket.timeout.ms/1000.0` | ||||||||||
:param float request_timeout: The overall request timeout in seconds, | ||||||||||
including broker lookup, request transmission, operation time | ||||||||||
on broker, and response. Default: `socket.timeout.ms*1000.0` | ||||||||||
pranavrth marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
@@ -576,7 +588,8 @@ def delete_topics(self, topics, **kwargs): | |||||||||
:param float operation_timeout: The operation timeout in seconds, | ||||||||||
controlling how long the DeleteTopics request will block | ||||||||||
on the broker waiting for the topic deletion to propagate | ||||||||||
in the cluster. A value of 0 returns immediately. Default: 0 | ||||||||||
in the cluster. A value of 0 returns immediately. | ||||||||||
Default: `socket.timeout.ms/1000.0` | ||||||||||
:param float request_timeout: The overall request timeout in seconds, | ||||||||||
including broker lookup, request transmission, operation time | ||||||||||
on broker, and response. Default: `socket.timeout.ms*1000.0` | ||||||||||
|
@@ -614,7 +627,8 @@ def create_partitions(self, new_partitions, **kwargs): | |||||||||
:param float operation_timeout: The operation timeout in seconds, | ||||||||||
controlling how long the CreatePartitions request will block | ||||||||||
on the broker waiting for the partition creation to propagate | ||||||||||
in the cluster. A value of 0 returns immediately. Default: 0 | ||||||||||
in the cluster. A value of 0 returns immediately. | ||||||||||
Default: `socket.timeout.ms/1000.0` | ||||||||||
:param float request_timeout: The overall request timeout in seconds, | ||||||||||
including broker lookup, request transmission, operation time | ||||||||||
on broker, and response. Default: `socket.timeout.ms*1000.0` | ||||||||||
|
@@ -1204,3 +1218,38 @@ def list_offsets(self, topic_partition_offsets, **kwargs): | |||||||||
|
||||||||||
super(AdminClient, self).list_offsets(topic_partition_offsets_list, f, **kwargs) | ||||||||||
return futmap | ||||||||||
|
||||||||||
def delete_records(self, topic_partition_offsets, **kwargs): | ||||||||||
""" | ||||||||||
Deletes all the records before the specified offsets (not including), | ||||||||||
in the specified Topic and Partitions. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Written this way they seem like classes
Suggested change
|
||||||||||
|
||||||||||
param list(TopicPartitions) topic_partition_offsets: A list of | ||||||||||
emasab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
TopicPartition objects having `offset` field set to the offset | ||||||||||
before which all the records should be deleted. | ||||||||||
emasab marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
:param float request_timeout: The overall request timeout in seconds, | ||||||||||
including broker lookup, request transmission, operation time | ||||||||||
on broker, and response. Default: `socket.timeout.ms*1000.0` | ||||||||||
:param float operation_timeout: The operation timeout in seconds, | ||||||||||
PratRanj07 marked this conversation as resolved.
Show resolved
Hide resolved
emasab marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
controlling how long the delete_records request will block | ||||||||||
on the broker waiting for the record deletion to propagate | ||||||||||
in the cluster. A value of 0 returns immediately. | ||||||||||
Default: `socket.timeout.ms/1000.0` | ||||||||||
|
||||||||||
:returns: A dict of futures keyed by the TopicPartition. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
The future result() method returns DeletedRecords | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
or raises KafkaException | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
:rtype: dict[TopicPartition, future] | ||||||||||
|
||||||||||
:raises KafkaException: Operation failed locally or on broker. | ||||||||||
:raises TypeError: Invalid input type. | ||||||||||
:raises ValueError: Invalid input value. | ||||||||||
""" | ||||||||||
AdminClient._check_delete_records(topic_partition_offsets) | ||||||||||
|
||||||||||
f, futmap = AdminClient._make_futures_v2( | ||||||||||
topic_partition_offsets, _TopicPartition, AdminClient._make_futmap_result) | ||||||||||
|
||||||||||
super(AdminClient, self).delete_records(topic_partition_offsets, f, **kwargs) | ||||||||||
return futmap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
DeletedRecords
toindex.rst
afterConsumerGroupDescription
and