मुख्य सामग्री पर जाएं
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

किसी एंडपॉइंट से डेटा स्ट्रीम करें, जिसमें स्वचालित पुन:कनेक्शन और घातीय बैकऑफ़ शामिल है। यह फ़ंक्शन पूरे कनेक्शन प्रबंधन को संभालता है, जिसमें शामिल हैं:
  • डिस्कनेक्ट होने पर स्वचालित पुन:कनेक्शन
  • पुनः प्रयास में देरी के लिए jitter के साथ घातीय बैकऑफ़
  • errors को retryable बनाम fatal के रूप में वर्गीकृत करना
  • कनेक्शन स्थिति की निगरानी के लिए lifecycle callbacks

पैरामीटर

path.session
Session
HTTP कॉल के लिए उपयोग की जाने वाली requests Session।
path.method
str
HTTP method (आमतौर पर “get”)।
path.url
str
जिससे स्ट्रीम करना है, उसका पूरा URL।
path.config
StreamConfig
पुनः प्रयास और callback सेटिंग्स के साथ StreamConfig।