Apache Thrift: IDL से बहुभाषी RPC client बनाना
Apache Thrift RPC और serialization का tool है। Interface Definition Language (IDL) में types और services घोषित होते हैं; compiler कई programming languages के लिए code बनाता है। Service definition, generated processing code, data protocol और transport को अलग समझें: साझा Thrift IDL अपने आप compatible wire protocol या operational configuration तय नहीं करता।
Apache Thrift RPC और serialization का tool है। Interface Definition Language (IDL) में types और services घोषित होते हैं; compiler कई programming languages के लिए code बनाता है। Service definition, generated processing code, data protocol और transport को अलग समझें: साझा Thrift IDL अपने आप compatible wire protocol या operational configuration तय नहीं करता।
घटक कैसे जुड़ते हैं
.thrift फ़ाइल struct, enum, exception, service method और request/response type घोषित करती है। Compiler हर भाषा के लिए types तथा client/server code बनाता है। Server handler business logic लागू करता है; generated processor wire message पढ़कर handler बुलाता और response लिखता है।
Transport bytes पढ़ता/लिखता है। Protocol उसी transport पर Thrift values encode/decode करता है। Server transport, input/output protocol, generated processor और handler जोड़ता है। दोनों सिरों पर compatible protocol, transport/framing, service और method contract तथा authentication/TLS जैसी security settings तय होनी चाहिए।
IDL सावधानी से बदलें
Service या message बदलने पर हर भाषा का code फिर generate करना और compatible client/server संयोजन deploy करना पड़ सकता है। Field ID, requiredness, type या exception बदलने से पहले Thrift release और भाषा implementation के compatibility नियम देखें। Field ID दोबारा न लें और जाँच के बिना मौजूदा request/response न तोड़ें। नए optional fields और चरणबद्ध rollout को उपभोक्ता संस्करणों के साथ जाँचें।
Thrift transport से अलग binary, compact और JSON जैसे protocol देता है। अपने release के दस्तावेज़ में विकल्प और भाषा-समर्थन देखें; सभी bindings का व्यवहार समान न मानें।
अपनाने और समस्या-निवारण की सूची
Version-controlled IDL और request/response types देखें।
Compiler और language generator संस्करण लिखें; code फिर बनाएँ।
दोनों सिरों का transport, protocol, framing, port और security जाँचें।
पुष्टि करें कि generated client processor और handler तक पहुँचता है और दोनों पक्ष responses/exceptions को समान ढंग से समझते हैं।
चरणबद्ध deployment से पहले पुराने/नए client-server संयोजन जाँचें।
Thrift API boundary पर types और calls साझा करता है, लेकिन सभी operational policies तय नहीं करता। Project की भाषा, protocol, transport, code generation और security तय करके उसी संयोजन को सत्यापित करें।
स्रोत
[Apache Thrift: Concepts](https://thrift.apache.org/docs/concepts.html)
[Apache Thrift: Interface Definition Language](https://thrift.apache.org/docs/idl)
[Apache Thrift Documentation](https://thrift.apache.org/docs/)