메인 콘텐츠로 건너뛰기
X API SDK를 위한 강력한 스트리밍 유틸리티입니다. 이 모듈은 자동 재연결, 지수적 백오프, 포괄적인 오류 처리를 포함한 스트리밍 연결 관리를 제공합니다. 클라이언트는 연결 관리를 신경 쓰지 않고 스트리밍 엔드포인트에서 데이터를 소비할 수 있으며, SDK가 모든 복구 작업을 자동으로 처리합니다.

class xdk.streaming.StreamConfig

재시도 동작이 포함된 스트리밍 연결 구성.

매개변수

path.max_retries
int
기본값:"10"
path.initial_backoff
float
기본값:"1.0"
path.max_backoff
float
기본값:"64.0"
path.backoff_multiplier
float
기본값:"2.0"
path.jitter
bool
기본값:"True"
path.timeout
float or None
기본값:"None"
path.chunk_size
int
기본값:"1024"
path.on_connect
Callable[[], None] or None
기본값:"None"
path.on_disconnect
Callable[[Exception or None], None] or None
기본값:"None"
path.on_reconnect
Callable[[int, float], None] or None
기본값:"None"
path.on_error
Callable[[[StreamError

__init__

파라미터

path.max_retries
int
기본값:"10"
path.initial_backoff
float
기본값:"1.0"
path.max_backoff
float
기본값:"64.0"
path.backoff_multiplier
float
기본값:"2.0"
path.jitter
bool
기본값:"True"
path.timeout
float or None
기본값:"None"
path.chunk_size
int
기본값:"1024"
path.on_connect
Callable[[], None] or None
기본값:"None"
path.on_disconnect
Callable[[Exception or None], None] or None
기본값:"None"
path.on_reconnect
Callable[[int, float], None] or None
기본값:"None"
path.on_error
Callable[[[StreamError

on_error : Callable[[[StreamError]

exception xdk.streaming.StreamError

분류 정보가 포함된 스트리밍 오류를 나타내는 예외입니다.

매개변수

path.message
str
path.error_type
StreamErrorType

__init__

매개변수

path.message
str
path.error_type
StreamErrorType

class xdk.streaming.StreamErrorType

재시도 결정을 위한 스트리밍 오류 분류입니다.

매개변수

path.value
Any

class xdk.streaming.StreamState

스트리밍 연결의 내부 상태를 나타내는 클래스입니다.

매개변수

path.retry_count
int
기본값:"0"
path.current_backoff
float
기본값:"1.0"
path.is_connected
bool
기본값:"False"
path.total_items_received
int
기본값:"0"
path.last_error
StreamError

__init__

매개변수

path.retry_count
int
기본값:"0"
path.current_backoff
float
기본값:"1.0"
path.is_connected
bool
기본값:"False"
path.total_items_received
int
기본값:"0"
path.last_error
StreamError

last_error : [StreamError]

xdk.streaming.stream_with_retry

자동 재연결 및 지수 백오프를 사용하여 엔드포인트에서 데이터를 스트리밍합니다. 이 함수는 다음을 포함한 모든 연결 관리를 처리합니다:
  • 연결이 끊어졌을 때 자동으로 재연결
  • 재시도 지연을 위한 지터가 포함된 지수 백오프
  • errors를 재시도 가능한 오류와 치명적인 오류로 분류
  • 라이프사이클 콜백을 통한 연결 상태 모니터링

매개변수

path.session
Session
HTTP 요청에 사용할 requests Session 인스턴스입니다.
path.method
str
HTTP 메서드(일반적으로 “GET”)입니다.
path.url
str
스트리밍에 사용할 전체 URL입니다.
path.config
StreamConfig
재시도 및 콜백 설정을 포함하는 StreamConfig입니다.