@@ -40,6 +40,8 @@ async def publish(
4040 content_type : Optional [str ] = None ,
4141 method : Optional [HttpMethod ] = None ,
4242 headers : Optional [Dict [str , str ]] = None ,
43+ callback_headers : Optional [Dict [str , str ]] = None ,
44+ failure_callback_headers : Optional [Dict [str , str ]] = None ,
4345 retries : Optional [int ] = None ,
4446 callback : Optional [str ] = None ,
4547 failure_callback : Optional [str ] = None ,
@@ -67,6 +69,9 @@ async def publish(
6769 :param content_type: MIME type of the message.
6870 :param method: The HTTP method to use when sending a webhook to your API.
6971 :param headers: Headers to forward along with the message.
72+ :param callback_headers: Headers to forward along with the callback message.
73+ :param failure_callback_headers: Headers to forward along with the failure
74+ callback message.
7075 :param retries: How often should this message be retried in case the destination
7176 API is not available.
7277 :param callback: A callback url that will be called after each attempt.
@@ -86,8 +91,8 @@ async def publish(
8691 When a timeout is specified, it will be used instead of the maximum timeout
8792 value permitted by the QStash plan. It is useful in scenarios, where a message
8893 should be delivered with a shorter timeout.
89- :param flow_control: Settings for controlling the number of active requests and
90- number of requests per second with the same key.
94+ :param flow_control: Settings for controlling the number of active requests,
95+ as well as the rate of requests with the same flow control key.
9196 """
9297 headers = headers or {}
9398 destination = get_destination (
@@ -101,6 +106,8 @@ async def publish(
101106 content_type = content_type ,
102107 method = method ,
103108 headers = headers ,
109+ callback_headers = callback_headers ,
110+ failure_callback_headers = failure_callback_headers ,
104111 retries = retries ,
105112 callback = callback ,
106113 failure_callback = failure_callback ,
@@ -130,6 +137,8 @@ async def publish_json(
130137 body : Optional [Any ] = None ,
131138 method : Optional [HttpMethod ] = None ,
132139 headers : Optional [Dict [str , str ]] = None ,
140+ callback_headers : Optional [Dict [str , str ]] = None ,
141+ failure_callback_headers : Optional [Dict [str , str ]] = None ,
133142 retries : Optional [int ] = None ,
134143 callback : Optional [str ] = None ,
135144 failure_callback : Optional [str ] = None ,
@@ -158,6 +167,9 @@ async def publish_json(
158167 serialized as JSON string.
159168 :param method: The HTTP method to use when sending a webhook to your API.
160169 :param headers: Headers to forward along with the message.
170+ :param callback_headers: Headers to forward along with the callback message.
171+ :param failure_callback_headers: Headers to forward along with the failure
172+ callback message.
161173 :param retries: How often should this message be retried in case the destination
162174 API is not available.
163175 :param callback: A callback url that will be called after each attempt.
@@ -177,8 +189,8 @@ async def publish_json(
177189 When a timeout is specified, it will be used instead of the maximum timeout
178190 value permitted by the QStash plan. It is useful in scenarios, where a message
179191 should be delivered with a shorter timeout.
180- :param flow_control: Settings for controlling the number of active requests and
181- number of requests per second with the same key.
192+ :param flow_control: Settings for controlling the number of active requests,
193+ as well as the rate of requests with the same flow control key.
182194 """
183195 return await self .publish (
184196 url = url ,
@@ -188,6 +200,8 @@ async def publish_json(
188200 content_type = "application/json" ,
189201 method = method ,
190202 headers = headers ,
203+ callback_headers = callback_headers ,
204+ failure_callback_headers = failure_callback_headers ,
191205 retries = retries ,
192206 callback = callback ,
193207 failure_callback = failure_callback ,
@@ -210,6 +224,8 @@ async def enqueue(
210224 content_type : Optional [str ] = None ,
211225 method : Optional [HttpMethod ] = None ,
212226 headers : Optional [Dict [str , str ]] = None ,
227+ callback_headers : Optional [Dict [str , str ]] = None ,
228+ failure_callback_headers : Optional [Dict [str , str ]] = None ,
213229 retries : Optional [int ] = None ,
214230 callback : Optional [str ] = None ,
215231 failure_callback : Optional [str ] = None ,
@@ -236,6 +252,9 @@ async def enqueue(
236252 :param content_type: MIME type of the message.
237253 :param method: The HTTP method to use when sending a webhook to your API.
238254 :param headers: Headers to forward along with the message.
255+ :param callback_headers: Headers to forward along with the callback message.
256+ :param failure_callback_headers: Headers to forward along with the failure
257+ callback message.
239258 :param retries: How often should this message be retried in case the destination
240259 API is not available.
241260 :param callback: A callback url that will be called after each attempt.
@@ -261,6 +280,8 @@ async def enqueue(
261280 content_type = content_type ,
262281 method = method ,
263282 headers = headers ,
283+ callback_headers = callback_headers ,
284+ failure_callback_headers = failure_callback_headers ,
264285 retries = retries ,
265286 callback = callback ,
266287 failure_callback = failure_callback ,
@@ -291,6 +312,8 @@ async def enqueue_json(
291312 body : Optional [Any ] = None ,
292313 method : Optional [HttpMethod ] = None ,
293314 headers : Optional [Dict [str , str ]] = None ,
315+ callback_headers : Optional [Dict [str , str ]] = None ,
316+ failure_callback_headers : Optional [Dict [str , str ]] = None ,
294317 retries : Optional [int ] = None ,
295318 callback : Optional [str ] = None ,
296319 failure_callback : Optional [str ] = None ,
@@ -318,6 +341,9 @@ async def enqueue_json(
318341 serialized as JSON string.
319342 :param method: The HTTP method to use when sending a webhook to your API.
320343 :param headers: Headers to forward along with the message.
344+ :param callback_headers: Headers to forward along with the callback message.
345+ :param failure_callback_headers: Headers to forward along with the failure
346+ callback message.
321347 :param retries: How often should this message be retried in case the destination
322348 API is not available.
323349 :param callback: A callback url that will be called after each attempt.
@@ -340,6 +366,8 @@ async def enqueue_json(
340366 content_type = "application/json" ,
341367 method = method ,
342368 headers = headers ,
369+ callback_headers = callback_headers ,
370+ failure_callback_headers = failure_callback_headers ,
343371 retries = retries ,
344372 callback = callback ,
345373 failure_callback = failure_callback ,
@@ -440,9 +468,9 @@ async def cancel_many(self, message_ids: List[str]) -> int:
440468 body = body ,
441469 )
442470
443- return response ["cancelled" ]
471+ return response ["cancelled" ] # type:ignore[no-any-return]
444472
445- async def cancel_all (self ):
473+ async def cancel_all (self ) -> int :
446474 """
447475 Cancels delivery of all the existing messages.
448476
@@ -457,4 +485,4 @@ async def cancel_all(self):
457485 method = "DELETE" ,
458486 )
459487
460- return response ["cancelled" ]
488+ return response ["cancelled" ] # type:ignore[no-any-return]
0 commit comments