Skip to content

Commit ad8d6b4

Browse files
committed
feat: ack_first added deprecated and docstrings to Ack_Policy
1 parent d64f9f5 commit ad8d6b4

File tree

7 files changed

+142
-9
lines changed

7 files changed

+142
-9
lines changed

faststream/confluent/broker/registrator.py

+46-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
overload,
1111
)
1212

13-
from typing_extensions import Doc, override
13+
from typing_extensions import Doc, deprecated, override
1414

1515
from faststream._internal.broker.abc_broker import ABCBroker
1616
from faststream._internal.constants import EMPTY
@@ -161,7 +161,13 @@ def subscriber(
161161
periodically committed in the background.
162162
""",
163163
),
164-
] = True,
164+
deprecated(
165+
"""
166+
This option is deprecated and will be removed in 0.7.0 release.
167+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
168+
""",
169+
),
170+
] = EMPTY,
165171
auto_commit_interval_ms: Annotated[
166172
int,
167173
Doc(
@@ -428,7 +434,13 @@ def subscriber(
428434
periodically committed in the background.
429435
""",
430436
),
431-
] = True,
437+
deprecated(
438+
"""
439+
This option is deprecated and will be removed in 0.7.0 release.
440+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
441+
""",
442+
),
443+
] = EMPTY,
432444
auto_commit_interval_ms: Annotated[
433445
int,
434446
Doc(
@@ -695,7 +707,13 @@ def subscriber(
695707
periodically committed in the background.
696708
""",
697709
),
698-
] = True,
710+
deprecated(
711+
"""
712+
This option is deprecated and will be removed in 0.7.0 release.
713+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
714+
""",
715+
),
716+
] = EMPTY,
699717
auto_commit_interval_ms: Annotated[
700718
int,
701719
Doc(
@@ -965,7 +983,13 @@ def subscriber(
965983
periodically committed in the background.
966984
""",
967985
),
968-
] = True,
986+
deprecated(
987+
"""
988+
This option is deprecated and will be removed in 0.7.0 release.
989+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
990+
""",
991+
),
992+
] = EMPTY,
969993
auto_commit_interval_ms: Annotated[
970994
int,
971995
Doc(
@@ -1130,7 +1154,23 @@ def subscriber(
11301154
"SpecificationDefaultSubscriber",
11311155
"SpecificationBatchSubscriber",
11321156
]:
1133-
if ack_policy is AckPolicy.ACK_FIRST:
1157+
if (
1158+
auto_commit is not EMPTY and auto_commit
1159+
and ack_policy is not EMPTY and ack_policy is not ack_policy.ACK_FIRST
1160+
) or (
1161+
auto_commit is not EMPTY and not auto_commit
1162+
and ack_policy is ack_policy.ACK_FIRST
1163+
):
1164+
msg = "You can't use conflict settings ('auto_commit' and 'ack_policy')"
1165+
raise SetupError(msg)
1166+
1167+
if auto_commit is not EMPTY and auto_commit and ack_policy is EMPTY:
1168+
ack_policy = AckPolicy.DO_NOTHING
1169+
1170+
elif auto_commit is not EMPTY and not auto_commit and ack_policy is EMPTY:
1171+
ack_policy = AckPolicy.REJECT_ON_ERROR
1172+
1173+
elif ack_policy is AckPolicy.ACK_FIRST:
11341174
auto_commit = True
11351175
ack_policy = AckPolicy.DO_NOTHING
11361176

faststream/confluent/fastapi/fastapi.py

+24
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ def subscriber(
699699
periodically committed in the background.
700700
""",
701701
),
702+
deprecated(
703+
"""
704+
This option is deprecated and will be removed in 0.7.0 release.
705+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
706+
""",
707+
),
702708
] = True,
703709
auto_commit_interval_ms: Annotated[
704710
int,
@@ -1089,6 +1095,12 @@ def subscriber(
10891095
periodically committed in the background.
10901096
""",
10911097
),
1098+
deprecated(
1099+
"""
1100+
This option is deprecated and will be removed in 0.7.0 release.
1101+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
1102+
""",
1103+
),
10921104
] = True,
10931105
auto_commit_interval_ms: Annotated[
10941106
int,
@@ -1469,6 +1481,12 @@ def subscriber(
14691481
periodically committed in the background.
14701482
""",
14711483
),
1484+
deprecated(
1485+
"""
1486+
This option is deprecated and will be removed in 0.7.0 release.
1487+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
1488+
""",
1489+
),
14721490
] = True,
14731491
auto_commit_interval_ms: Annotated[
14741492
int,
@@ -1862,6 +1880,12 @@ def subscriber(
18621880
periodically committed in the background.
18631881
""",
18641882
),
1883+
deprecated(
1884+
"""
1885+
This option is deprecated and will be removed in 0.7.0 release.
1886+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
1887+
""",
1888+
),
18651889
] = True,
18661890
auto_commit_interval_ms: Annotated[
18671891
int,

faststream/confluent/router.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Union,
1010
)
1111

12-
from typing_extensions import Doc
12+
from typing_extensions import Doc, deprecated
1313

1414
from faststream._internal.broker.router import (
1515
ArgsContainer,
@@ -247,6 +247,12 @@ def __init__(
247247
periodically committed in the background.
248248
""",
249249
),
250+
deprecated(
251+
"""
252+
This option is deprecated and will be removed in 0.7.0 release.
253+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
254+
""",
255+
),
250256
] = True,
251257
auto_commit_interval_ms: Annotated[
252258
int,

faststream/kafka/broker/registrator.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from aiokafka import ConsumerRecord
1515
from aiokafka.coordinator.assignors.roundrobin import RoundRobinPartitionAssignor
16-
from typing_extensions import Doc, override
16+
from typing_extensions import Doc, deprecated, override
1717

1818
from faststream._internal.broker.abc_broker import ABCBroker
1919
from faststream._internal.constants import EMPTY
@@ -167,6 +167,12 @@ def subscriber(
167167
periodically committed in the background.
168168
""",
169169
),
170+
deprecated(
171+
"""
172+
This option is deprecated and will be removed in 0.7.0 release.
173+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
174+
""",
175+
),
170176
] = True,
171177
auto_commit_interval_ms: Annotated[
172178
int,
@@ -533,6 +539,12 @@ def subscriber(
533539
periodically committed in the background.
534540
""",
535541
),
542+
deprecated(
543+
"""
544+
This option is deprecated and will be removed in 0.7.0 release.
545+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
546+
""",
547+
),
536548
] = True,
537549
auto_commit_interval_ms: Annotated[
538550
int,
@@ -899,6 +911,12 @@ def subscriber(
899911
periodically committed in the background.
900912
""",
901913
),
914+
deprecated(
915+
"""
916+
This option is deprecated and will be removed in 0.7.0 release.
917+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
918+
""",
919+
),
902920
] = True,
903921
auto_commit_interval_ms: Annotated[
904922
int,
@@ -1268,6 +1286,12 @@ def subscriber(
12681286
periodically committed in the background.
12691287
""",
12701288
),
1289+
deprecated(
1290+
"""
1291+
This option is deprecated and will be removed in 0.7.0 release.
1292+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
1293+
""",
1294+
),
12711295
] = True,
12721296
auto_commit_interval_ms: Annotated[
12731297
int,

faststream/kafka/fastapi/fastapi.py

+24
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@ def subscriber(
710710
periodically committed in the background.
711711
""",
712712
),
713+
deprecated(
714+
"""
715+
This option is deprecated and will be removed in 0.7.0 release.
716+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
717+
""",
718+
),
713719
] = True,
714720
auto_commit_interval_ms: Annotated[
715721
int,
@@ -1196,6 +1202,12 @@ def subscriber(
11961202
periodically committed in the background.
11971203
""",
11981204
),
1205+
deprecated(
1206+
"""
1207+
This option is deprecated and will be removed in 0.7.0 release.
1208+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
1209+
""",
1210+
),
11991211
] = True,
12001212
auto_commit_interval_ms: Annotated[
12011213
int,
@@ -1682,6 +1694,12 @@ def subscriber(
16821694
periodically committed in the background.
16831695
""",
16841696
),
1697+
deprecated(
1698+
"""
1699+
This option is deprecated and will be removed in 0.7.0 release.
1700+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
1701+
""",
1702+
),
16851703
] = True,
16861704
auto_commit_interval_ms: Annotated[
16871705
int,
@@ -2171,6 +2189,12 @@ def subscriber(
21712189
periodically committed in the background.
21722190
""",
21732191
),
2192+
deprecated(
2193+
"""
2194+
This option is deprecated and will be removed in 0.7.0 release.
2195+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
2196+
""",
2197+
),
21742198
] = True,
21752199
auto_commit_interval_ms: Annotated[
21762200
int,

faststream/kafka/router.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111

1212
from aiokafka.coordinator.assignors.roundrobin import RoundRobinPartitionAssignor
13-
from typing_extensions import Doc
13+
from typing_extensions import Doc, deprecated
1414

1515
from faststream._internal.broker.router import (
1616
ArgsContainer,
@@ -255,6 +255,12 @@ def __init__(
255255
periodically committed in the background.
256256
""",
257257
),
258+
deprecated(
259+
"""
260+
This option is deprecated and will be removed in 0.7.0 release.
261+
Please, use `ack_policy=AckPolicy.ACK_FIRST` instead.
262+
""",
263+
),
258264
] = True,
259265
auto_commit_interval_ms: Annotated[
260266
int,

faststream/middlewares/acknowledgement/conf.py

+9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33

44
class AckPolicy(str, Enum):
55
ACK_FIRST = "ack_first"
6+
"""Ack message on consume"""
7+
68
ACK = "ack"
9+
"""Ack message after all process"""
10+
711
REJECT_ON_ERROR = "reject_on_error"
12+
"""Reject message on unhandled exceptions"""
13+
814
NACK_ON_ERROR = "nack_on_error"
15+
"""Nack message on unhandled exceptions"""
16+
917
DO_NOTHING = "do_nothing"
18+
"""Not create AcknowledgementMiddleware"""

0 commit comments

Comments
 (0)