> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ストリーミング

X API SDK 向けの堅牢なストリーミングユーティリティ。

このモジュールは、自動再接続、指数バックオフ、包括的なエラーハンドリングを備えたストリーミング接続の管理機能を提供します。Client は接続管理を気にせずにストリーミングエンドポイントを利用でき、復旧はすべて SDK が自動的に処理します。

<div id="class-xdkstreamingstreamconfig">
  ### `class xdk.streaming.StreamConfig`
</div>

リトライ動作を伴うストリーミング接続の設定。

#### パラメータ

<ParamField path="path.max_retries" type="int" default="10" />

<ParamField path="path.initial_backoff" type="float" default="1.0" />

<ParamField path="path.max_backoff" type="float" default="64.0" />

<ParamField path="path.backoff_multiplier" type="float" default="2.0" />

<ParamField path="path.jitter" type="bool" default="True" />

<ParamField path="path.timeout" type="float or None" default="None" />

<ParamField path="path.chunk_size" type="int" default="1024" />

<ParamField path="path.on_connect" type="Callable[[], None] or None" default="None" />

<ParamField path="path.on_disconnect" type="Callable[[Exception or None], None] or None" default="None" />

<ParamField path="path.on_reconnect" type="Callable[[int, float], None] or None" default="None" />

<ParamField path="path.on_error" type="Callable[[[StreamError" />

<div id="__init__">
  ### `__init__`
</div>

#### パラメータ

<ParamField path="path.max_retries" type="int" default="10" />

<ParamField path="path.initial_backoff" type="float" default="1.0" />

<ParamField path="path.max_backoff" type="float" default="64.0" />

<ParamField path="path.backoff_multiplier" type="float" default="2.0" />

<ParamField path="path.jitter" type="bool" default="True" />

<ParamField path="path.timeout" type="float or None" default="None" />

<ParamField path="path.chunk_size" type="int" default="1024" />

<ParamField path="path.on_connect" type="Callable[[], None] or None" default="None" />

<ParamField path="path.on_disconnect" type="Callable[[Exception or None], None] or None" default="None" />

<ParamField path="path.on_reconnect" type="Callable[[int, float], None] or None" default="None" />

<ParamField path="path.on_error" type="Callable[[[StreamError" />

<div id="on_error-callablestreamerror">
  ### `on_error : Callable[[[StreamError]`
</div>

<div id="exception-xdkstreamingstreamerror">
  ### `exception xdk.streaming.StreamError`
</div>

分類情報を伴うストリーミングエラーが発生したときに送出される例外です。

#### パラメータ

<ParamField path="path.message" type="str" />

<ParamField path="path.error_type" type="StreamErrorType" />

<div id="__init__">
  ### `__init__`
</div>

#### パラメータ

<ParamField path="path.message" type="str" />

<ParamField path="path.error_type" type="StreamErrorType" />

<div id="class-xdkstreamingstreamerrortype">
  ### `class xdk.streaming.StreamErrorType`
</div>

再試行判断に用いるストリーミングエラーの分類。

#### パラメータ

<ParamField path="path.value" type="Any" />

<div id="class-xdkstreamingstreamstate">
  ### `class xdk.streaming.StreamState`
</div>

ストリーミング接続の内部状態を表します。

<div id="parameters">
  #### パラメーター
</div>

<ParamField path="path.retry_count" type="int" default="0" />

<ParamField path="path.current_backoff" type="float" default="1.0" />

<ParamField path="path.is_connected" type="bool" default="False" />

<ParamField path="path.total_items_received" type="int" default="0" />

<ParamField path="path.last_error" type="StreamError" />

<div id="__init__">
  ### `__init__`
</div>

#### パラメータ

<ParamField path="path.retry_count" type="int" default="0" />

<ParamField path="path.current_backoff" type="float" default="1.0" />

<ParamField path="path.is_connected" type="bool" default="False" />

<ParamField path="path.total_items_received" type="int" default="0" />

<ParamField path="path.last_error" type="StreamError" />

<div id="last_error-streamerror">
  ### `last_error : [StreamError]`
</div>

<div id="xdkstreamingstream_with_retry">
  ### `xdk.streaming.stream_with_retry`
</div>

自動再接続と指数バックオフを用いて、エンドポイントからデータをストリーミングします。
この関数は、以下を含むすべての接続管理を行います:

* 切断時の自動再接続
* リトライ待機時間に対するジッター付き指数バックオフ
* エラーを再試行可能なものと致命的なものに分類
* 接続状態を監視するためのライフサイクルコールバック

<div id="parameters">
  #### パラメーター
</div>

<ParamField path="path.session" type="Session">
  HTTP 呼び出しに使用する requests の Session オブジェクト。
</ParamField>

<ParamField path="path.method" type="str">
  HTTP メソッド（通常は「get」）。
</ParamField>

<ParamField path="path.url" type="str">
  ストリーミング元となる完全な URL。
</ParamField>

<ParamField path="path.config" type="StreamConfig">
  リトライおよびコールバック設定を含む StreamConfig。
</ParamField>
