I have a cluster of virtual nodes. Each OS is ubuntu
. I need to upload the .thrift
to each node and generate the .thrift
.
My problem is that the generation doesn't include the implementation of the functions. As far as I know, thrift is OS dependent. My local machine running win10
while virtual machines run ubuntu
Is there a way for me after generating on my local machine, implementing it, and testing it - to add the implementation to the .thrift
so that in next generate the api is implemented ?
Code implemented in Python if it matters.
Simply spoken, Thrift is about defining an API, or a service contract, between endpoints. The code generation step in Thrift usually takes place during development time, not at runtime. And the implementation is not part of that contract, for several reasons.
As you correctly noticed, especially in the RPC use case, client and server may reside on different platforms and may be written in different languages. But even if it is the same platform and only one language, the contract and its implementation are still two different things, and they should be.
The use case of uploading a
.thrift
IDL file to a server and have that server generate an endpoint plus implementation "on the fly" not only looks a bit strange to me, it also is not what I would call the typical Thrift use case. Last not least, in terms of security, such a scenario could quickly emerge into a nightmare.If we do not know the exact data structure, the approach of modeling the data in the IDL obviously needs to be very generic. Alternatively, using Avro (which is designed to deal with flexible data structures at runtime) or an entirely different approach might be more suitable in such a case.