Skip to content

Commit 63fcdd7

Browse files
committed
Update the documents
1 parent 7e68718 commit 63fcdd7

File tree

9 files changed

+39
-61
lines changed

9 files changed

+39
-61
lines changed

docs-src/audit-logs/index.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,14 @@ To use other retry handlers, you can pass a list of ``RetryHandler`` to the clie
6363
6464
import os
6565
from slack_sdk.audit_logs import AuditLogsClient
66-
from slack_sdk.http_retry import default_retry_handlers
67-
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
66+
client = AuditLogsClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"])
6867
6968
# This handler does retries when HTTP status 429 is returned
69+
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
7070
rate_limit_handler = RateLimitErrorRetryHandler(max_retry_count=1)
7171
72-
client = AuditLogsClient(
73-
token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"],
74-
# Enable rate limited error retries as well
75-
retry_handlers=default_retry_handlers + [rate_limit_handler],
76-
)
72+
# Enable rate limited error retries as well
73+
client.retry_handlers.append(rate_limit_handler)
7774
7875
Creating your own ones is also quite simple. Defining a new class that inherits ``slack_sdk.http_retry.RetryHandler`` (``AsyncRetryHandler`` for asyncio apps) and implements required methods (internals of ``can_retry`` / ``prepare_for_next_retry``). Check the built-in ones' source code for learning how to properly implement.
7976

docs-src/scim/index.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,14 @@ To use other retry handlers, you can pass a list of ``RetryHandler`` to the clie
111111
112112
import os
113113
from slack_sdk.scim import SCIMClient
114-
from slack_sdk.http_retry import default_retry_handlers
115-
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
114+
client = SCIMClient(token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"])
116115
117116
# This handler does retries when HTTP status 429 is returned
117+
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
118118
rate_limit_handler = RateLimitErrorRetryHandler(max_retry_count=1)
119119
120-
client = SCIMClient(
121-
token=os.environ["SLACK_ORG_ADMIN_USER_TOKEN"],
122-
# Enable rate limited error retries as well
123-
retry_handlers=default_retry_handlers + [rate_limit_handler],
124-
)
120+
# Enable rate limited error retries as well
121+
client.retry_handlers.append(rate_limit_handler)
125122
126123
Creating your own ones is also quite simple. Defining a new class that inherits ``slack_sdk.http_retry.RetryHandler`` (``AsyncRetryHandler`` for asyncio apps) and implements required methods (internals of ``can_retry`` / ``prepare_for_next_retry``). Check the built-in ones' source code for learning how to properly implement.
127124

docs-src/web/index.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,17 +665,14 @@ To use other retry handlers, you can pass a list of ``RetryHandler`` to the clie
665665
666666
import os
667667
from slack_sdk.web import WebClient
668-
from slack_sdk.http_retry import default_retry_handlers
669-
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
668+
client = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
670669
671670
# This handler does retries when HTTP status 429 is returned
671+
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
672672
rate_limit_handler = RateLimitErrorRetryHandler(max_retry_count=1)
673673
674-
client = WebClient(
675-
token=os.environ["SLACK_BOT_TOKEN"],
676-
# Enable rate limited error retries as well
677-
retry_handlers=default_retry_handlers + [rate_limit_handler],
678-
)
674+
# Enable rate limited error retries as well
675+
client.retry_handlers.append(rate_limit_handler)
679676
680677
Creating your own ones is also quite simple. Defining a new class that inherits ``slack_sdk.http_retry.RetryHandler`` (``AsyncRetryHandler`` for asyncio apps) and implements required methods (internals of ``can_retry`` / ``prepare_for_next_retry``). Check the built-in ones' source code for learning how to properly implement.
681678

docs-src/webhook/index.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,16 @@ To use other retry handlers, you can pass a list of ``RetryHandler`` to the clie
118118

119119
.. code-block:: python
120120
121-
from slack_sdk.http_retry import default_retry_handlers
122-
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
121+
from slack_sdk.webhook import WebhookClient
122+
url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
123+
webhook = WebhookClient(url=url)
124+
123125
# This handler does retries when HTTP status 429 is returned
126+
from slack_sdk.http_retry.builtin_handlers import RateLimitErrorRetryHandler
124127
rate_limit_handler = RateLimitErrorRetryHandler(max_retry_count=1)
125128
126-
from slack_sdk.webhook import WebhookClient
127-
url = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
128-
webhook = WebhookClient(
129-
url=url,
130-
# Enable rate limited error retries as well
131-
retry_handlers=default_retry_handlers + [rate_limit_handler],
132-
)
129+
# Enable rate limited error retries as well
130+
client.retry_handlers.append(rate_limit_handler)
133131
134132
Creating your own ones is also quite simple. Defining a new class that inherits ``slack_sdk.http_retry.RetryHandler`` (``AsyncRetryHandler`` for asyncio apps) and implements required methods (internals of ``can_retry`` / ``prepare_for_next_retry``). Check the built-in ones' source code for learning how to properly implement.
135133

docs/audit-logs/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,14 @@ <h2>RetryHandler<a class="headerlink" href="#retryhandler" title="Permalink to t
254254
<p>To use other retry handlers, you can pass a list of <code class="docutils literal notranslate"><span class="pre">RetryHandler</span></code> to the client constructor. For instance, you can add the built-in <code class="docutils literal notranslate"><span class="pre">RateLimitErrorRetryHandler</span></code> this way:</p>
255255
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
256256
<span class="kn">from</span> <span class="nn">slack_sdk.audit_logs</span> <span class="kn">import</span> <span class="n">AuditLogsClient</span>
257-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry</span> <span class="kn">import</span> <span class="n">default_retry_handlers</span>
258-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
257+
<span class="n">client</span> <span class="o">=</span> <span class="n">AuditLogsClient</span><span class="p">(</span><span class="n">token</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_ORG_ADMIN_USER_TOKEN&quot;</span><span class="p">])</span>
259258

260259
<span class="c1"># This handler does retries when HTTP status 429 is returned</span>
260+
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
261261
<span class="n">rate_limit_handler</span> <span class="o">=</span> <span class="n">RateLimitErrorRetryHandler</span><span class="p">(</span><span class="n">max_retry_count</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
262262

263-
<span class="n">client</span> <span class="o">=</span> <span class="n">AuditLogsClient</span><span class="p">(</span>
264-
<span class="n">token</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_ORG_ADMIN_USER_TOKEN&quot;</span><span class="p">],</span>
265-
<span class="c1"># Enable rate limited error retries as well</span>
266-
<span class="n">retry_handlers</span><span class="o">=</span><span class="n">default_retry_handlers</span> <span class="o">+</span> <span class="p">[</span><span class="n">rate_limit_handler</span><span class="p">],</span>
267-
<span class="p">)</span>
263+
<span class="c1"># Enable rate limited error retries as well</span>
264+
<span class="n">client</span><span class="o">.</span><span class="n">retry_handlers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">rate_limit_handler</span><span class="p">)</span>
268265
</pre></div>
269266
</div>
270267
<p>Creating your own ones is also quite simple. Defining a new class that inherits <code class="docutils literal notranslate"><span class="pre">slack_sdk.http_retry.RetryHandler</span></code> (<code class="docutils literal notranslate"><span class="pre">AsyncRetryHandler</span></code> for asyncio apps) and implements required methods (internals of <code class="docutils literal notranslate"><span class="pre">can_retry</span></code> / <code class="docutils literal notranslate"><span class="pre">prepare_for_next_retry</span></code>). Check the built-in ones’ source code for learning how to properly implement.</p>

docs/scim/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,14 @@ <h2>RetryHandler<a class="headerlink" href="#retryhandler" title="Permalink to t
301301
<p>To use other retry handlers, you can pass a list of <code class="docutils literal notranslate"><span class="pre">RetryHandler</span></code> to the client constructor. For instance, you can add the built-in <code class="docutils literal notranslate"><span class="pre">RateLimitErrorRetryHandler</span></code> this way:</p>
302302
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
303303
<span class="kn">from</span> <span class="nn">slack_sdk.scim</span> <span class="kn">import</span> <span class="n">SCIMClient</span>
304-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry</span> <span class="kn">import</span> <span class="n">default_retry_handlers</span>
305-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
304+
<span class="n">client</span> <span class="o">=</span> <span class="n">SCIMClient</span><span class="p">(</span><span class="n">token</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_ORG_ADMIN_USER_TOKEN&quot;</span><span class="p">])</span>
306305

307306
<span class="c1"># This handler does retries when HTTP status 429 is returned</span>
307+
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
308308
<span class="n">rate_limit_handler</span> <span class="o">=</span> <span class="n">RateLimitErrorRetryHandler</span><span class="p">(</span><span class="n">max_retry_count</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
309309

310-
<span class="n">client</span> <span class="o">=</span> <span class="n">SCIMClient</span><span class="p">(</span>
311-
<span class="n">token</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_ORG_ADMIN_USER_TOKEN&quot;</span><span class="p">],</span>
312-
<span class="c1"># Enable rate limited error retries as well</span>
313-
<span class="n">retry_handlers</span><span class="o">=</span><span class="n">default_retry_handlers</span> <span class="o">+</span> <span class="p">[</span><span class="n">rate_limit_handler</span><span class="p">],</span>
314-
<span class="p">)</span>
310+
<span class="c1"># Enable rate limited error retries as well</span>
311+
<span class="n">client</span><span class="o">.</span><span class="n">retry_handlers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">rate_limit_handler</span><span class="p">)</span>
315312
</pre></div>
316313
</div>
317314
<p>Creating your own ones is also quite simple. Defining a new class that inherits <code class="docutils literal notranslate"><span class="pre">slack_sdk.http_retry.RetryHandler</span></code> (<code class="docutils literal notranslate"><span class="pre">AsyncRetryHandler</span></code> for asyncio apps) and implements required methods (internals of <code class="docutils literal notranslate"><span class="pre">can_retry</span></code> / <code class="docutils literal notranslate"><span class="pre">prepare_for_next_retry</span></code>). Check the built-in ones’ source code for learning how to properly implement.</p>

docs/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/web/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -748,17 +748,14 @@ <h2>RetryHandler<a class="headerlink" href="#retryhandler" title="Permalink to t
748748
<p>To use other retry handlers, you can pass a list of <code class="docutils literal notranslate"><span class="pre">RetryHandler</span></code> to the client constructor. For instance, you can add the built-in <code class="docutils literal notranslate"><span class="pre">RateLimitErrorRetryHandler</span></code> this way:</p>
749749
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
750750
<span class="kn">from</span> <span class="nn">slack_sdk.web</span> <span class="kn">import</span> <span class="n">WebClient</span>
751-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry</span> <span class="kn">import</span> <span class="n">default_retry_handlers</span>
752-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
751+
<span class="n">client</span> <span class="o">=</span> <span class="n">WebClient</span><span class="p">(</span><span class="n">token</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_BOT_TOKEN&quot;</span><span class="p">])</span>
753752

754753
<span class="c1"># This handler does retries when HTTP status 429 is returned</span>
754+
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
755755
<span class="n">rate_limit_handler</span> <span class="o">=</span> <span class="n">RateLimitErrorRetryHandler</span><span class="p">(</span><span class="n">max_retry_count</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
756756

757-
<span class="n">client</span> <span class="o">=</span> <span class="n">WebClient</span><span class="p">(</span>
758-
<span class="n">token</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;SLACK_BOT_TOKEN&quot;</span><span class="p">],</span>
759-
<span class="c1"># Enable rate limited error retries as well</span>
760-
<span class="n">retry_handlers</span><span class="o">=</span><span class="n">default_retry_handlers</span> <span class="o">+</span> <span class="p">[</span><span class="n">rate_limit_handler</span><span class="p">],</span>
761-
<span class="p">)</span>
757+
<span class="c1"># Enable rate limited error retries as well</span>
758+
<span class="n">client</span><span class="o">.</span><span class="n">retry_handlers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">rate_limit_handler</span><span class="p">)</span>
762759
</pre></div>
763760
</div>
764761
<p>Creating your own ones is also quite simple. Defining a new class that inherits <code class="docutils literal notranslate"><span class="pre">slack_sdk.http_retry.RetryHandler</span></code> (<code class="docutils literal notranslate"><span class="pre">AsyncRetryHandler</span></code> for asyncio apps) and implements required methods (internals of <code class="docutils literal notranslate"><span class="pre">can_retry</span></code> / <code class="docutils literal notranslate"><span class="pre">prepare_for_next_retry</span></code>). Check the built-in ones’ source code for learning how to properly implement.</p>

docs/webhook/index.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,16 @@ <h2>AsyncWebhookClient<a class="headerlink" href="#asyncwebhookclient" title="Pe
310310
<h2>RetryHandler<a class="headerlink" href="#retryhandler" title="Permalink to this headline"></a></h2>
311311
<p>With the default settings, only <code class="docutils literal notranslate"><span class="pre">ConnectionErrorRetryHandler</span></code> with its default configuration (=only one retry in the manner of <a class="reference external" href="https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/">exponential backoff and jitter</a> is enabled. The retry handler retries if an API client encounters a connectivity-related failure (e.g., Connection reset by peer).</p>
312312
<p>To use other retry handlers, you can pass a list of <code class="docutils literal notranslate"><span class="pre">RetryHandler</span></code> to the client constructor. For instance, you can add the built-in <code class="docutils literal notranslate"><span class="pre">RateLimitErrorRetryHandler</span></code> this way:</p>
313-
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">slack_sdk.http_retry</span> <span class="kn">import</span> <span class="n">default_retry_handlers</span>
314-
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
313+
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">slack_sdk.webhook</span> <span class="kn">import</span> <span class="n">WebhookClient</span>
314+
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
315+
<span class="n">webhook</span> <span class="o">=</span> <span class="n">WebhookClient</span><span class="p">(</span><span class="n">url</span><span class="o">=</span><span class="n">url</span><span class="p">)</span>
316+
315317
<span class="c1"># This handler does retries when HTTP status 429 is returned</span>
318+
<span class="kn">from</span> <span class="nn">slack_sdk.http_retry.builtin_handlers</span> <span class="kn">import</span> <span class="n">RateLimitErrorRetryHandler</span>
316319
<span class="n">rate_limit_handler</span> <span class="o">=</span> <span class="n">RateLimitErrorRetryHandler</span><span class="p">(</span><span class="n">max_retry_count</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
317320

318-
<span class="kn">from</span> <span class="nn">slack_sdk.webhook</span> <span class="kn">import</span> <span class="n">WebhookClient</span>
319-
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX&quot;</span>
320-
<span class="n">webhook</span> <span class="o">=</span> <span class="n">WebhookClient</span><span class="p">(</span>
321-
<span class="n">url</span><span class="o">=</span><span class="n">url</span><span class="p">,</span>
322-
<span class="c1"># Enable rate limited error retries as well</span>
323-
<span class="n">retry_handlers</span><span class="o">=</span><span class="n">default_retry_handlers</span> <span class="o">+</span> <span class="p">[</span><span class="n">rate_limit_handler</span><span class="p">],</span>
324-
<span class="p">)</span>
321+
<span class="c1"># Enable rate limited error retries as well</span>
322+
<span class="n">client</span><span class="o">.</span><span class="n">retry_handlers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">rate_limit_handler</span><span class="p">)</span>
325323
</pre></div>
326324
</div>
327325
<p>Creating your own ones is also quite simple. Defining a new class that inherits <code class="docutils literal notranslate"><span class="pre">slack_sdk.http_retry.RetryHandler</span></code> (<code class="docutils literal notranslate"><span class="pre">AsyncRetryHandler</span></code> for asyncio apps) and implements required methods (internals of <code class="docutils literal notranslate"><span class="pre">can_retry</span></code> / <code class="docutils literal notranslate"><span class="pre">prepare_for_next_retry</span></code>). Check the built-in ones’ source code for learning how to properly implement.</p>

0 commit comments

Comments
 (0)