Apache Thrift
Sign in to saveIDL usato come framework per chiamate di procedura remota
Official website
Apache Thrift - Home
thrift.apache.org →Link to the official site · 7,690 chars · not written by Vinony
Described at
dance,focusingonthekey typesavailableinallprogramminglan- guages,ommittingany nichetypesavailableonlyinspecificlan- guages. ThebasetypessupportedbyThriftare: boolA booleanvalue,trueorfalse byteA signedbyte i16A 16-bitsignedinteger i32A 32-bitsignedinteger i64A 64-bitsignedinteger doubleA 64-bitfloatingpointnumber stringAnencoding-agnostictextorbinarystring Ofparticularnoteis theabsenceofunsignedintegertypes.Because thesetypeshave nodirecttranslationtonative primitive types inmany languages,theadvantagesthey affordarelost.Further, thereis nowaytopreventtheapplicationdeveloperina language like Pythonfromassigninga negative valuetoanintegervariable, leadingtounpredictablebehavior. Froma designstandpoint,we observedthatunsignedintegerswereveryrarely, if ever, usedfor arithmeticpurposes,butinpracticeweremuchmoreoftenused askeysoridentifiers.Inthiscase,thesignisirrelevant.Signed integersserve thissamepurposeandcanbesafelycasttotheir unsignedcounterparts(mostcommonlyinC++)whenabsolutely necessary. 2.2Structs AThriftstructdefinesa commonobjecttobeusedacrosslan- guages.Astructisessentiallyequivalenttoa classinobjectori- entedprogramminglanguages.A structhasa setofstronglytyped fields,eachwitha uniquenameidentifier. Thebasicsyntaxfor defininga Thriftstructlooksverysimilartoa C structdefinition. Fieldsmaybeannotatedwithanintegerfieldidentifier(uniqueto thescopeofthatstruct)andoptionaldefaultvalues.Fieldidentifiers willbeautomaticallyassignedif omitted,thoughthey arestrongly encouragedforversioningreasonsdiscussedlater. 2.3Containers Thriftcontainersarestronglytypedcontainersthatmaptothemost commonlyusedcontainersincommonprogramminglanguages. They areannotatedusingtheC++template(orJava Generics)style. Therearethreetypesavailable: list<type>Anorderedlistofelements.Translatesdirectly intoanSTLvector, JavaArrayList, ornative arrayinscript- inglanguages.Maycontainduplicates. set<type>Anunorderedsetofuniqueelements.Translates intoanSTLset, JavaHashSet,setinPython,ornative dictionaryinPHP/Ruby. map<type1,type2>Amapofstrictlyuniquekeystovalues TranslatesintoanSTLmap, JavaHashMap, PHPassociative array, orPython/Rubydictionary. Whiledefaultsareprovided,thetypemappingsarenotexplic- itlyfixed.Customcodegeneratordirectiveshave beenaddedto substitutecustomtypesindestinationlanguages(i.e.hash mapor Google’s sparsehashmapcanbeusedinC++).Theonlyrequire- mentisthatthecustomtypessupportallthenecessaryiteration primitives.Containerelementsmaybeofany validThrifttype,in- cludingothercontainersorstructs. structExample{ 1:i32number=10, 2:i64bigNumber, 3:doubledecimals, 4:stringname="thrifty" } Inthetargetlanguage,eachdefinitiongeneratesa typewithtwo methods,readandwrite, whichperformserializationandtrans- portoftheobjectsusinga ThriftTProtocolobject. 2.4Exceptions Exceptionsaresyntacticallyandfunctionallyequivalenttostructs exceptthatthey aredeclaredusingtheexceptionkeywordinstead ofthestructkeyword. Thegeneratedobjectsinheritfromanexceptionbaseclassasap- propriateineachtargetprogramminglanguage,inordertoseam- lesslyintegratewithnative exceptionhandlinginany givenlan- guage.Again,thedesignemphasisis onmakingthecodefamiliar totheapplicationdeveloper. 2.5Services ServicesaredefinedusingThrifttypes.Definitionofa serviceis semanticallyequivalenttodefininganinterface(ora purevirtual abstractclass)in objectorientedprogramming.TheThriftcompiler generatesfullyfunctionalclientandserver stubsthatimplementthe interface.Servicesaredefinedasfollows: service<name>{ <returntype><name>(<arguments>) [throws(<exceptions>)] ... } Anexample: serviceStringCache{ voidset(1:i32key,2:stringvalue), stringget(1:i32key)throws(1:KeyNotFoundknf), voiddelete(1:i32key) } Notethatvoidisa validtypefora functionreturn,inaddition toallotherdefinedThrifttypes.Additionally, anasyncmodifier keywordmaybeaddedtoavoidfunction,whichwillgenerate codethatdoesnotwaitfora responsefromtheserver. Notethata purevoidfunctionwillretur
Excerpt from a page describing this subject · 38,933 chars · not written by Vinony
Wikidata facts
- Developer
- Apache Software Foundation
- Official website
- thrift.apache.org
- Has use
- server software
Show 11 more facts
- copyright license
- Apache Software License 2.0
- described at URL
- thrift.apache.org/static/files/thrift-20070401.pdf
- operating system
- Microsoft Windows
- software version identifier
- 0.22.0
- programmed in
- Smalltalk
- source code repository URL
- github.com/apache/thrift.git
- publication date
- 2007-00-00
- issue tracker URL
- issues.apache.org/jira/browse/THRIFT
- inception
- 2012-04-14
- download URL
- thrift.apache.org/download
- Commons category
- Apache Thrift
Sources (3)
via Wikidata · CC0
Article · Italiano
Apache Thrift è un linguaggio di definizione di interfaccia usato per definire e creare servizi per diversi linguaggi informatici, in dettaglio. un protocollo di comunicazione binario.È usato come framework per procedure di chiamata remota (RPC) e fu sviluppato presso Facebook per lo "sviluppo di servizi per linguaggi scalabili". Combina un software stack con un motore della generazione di codice per costruire servizi che lavora efficientemente per diversi gradi e senza soluzione di continuità tra Delphi, C#, C++ (su sistemi POSIX compatibili), , Cocoa, Erlang, Go, Haskell, Java, OCaml, Perl, PHP, Python, Ruby, Node.js e Smalltalk. Sebbene sviluppato presso Facebook, ora è un progetto open source presso la Apache Software Foundation. L'implementazione fu descritta in un articolo tecnico reso disponibile su Facebook nell'aprile 2007, ora presente su Apache.
Abstract from DBpedia / Wikipedia · CC BY-SA