mercredi 17 juin 2020

Good design for multi-language subscriber in Python

I have a server running which can be queried to get the some specific data. The subscriber API has its implementation in Python, Java and C++. Most of us are very much used to working with Python so I have created python launcher scripts to launch the Java/C++ subscriber.

What I have done is this, created a handle API which takes the argument language. - If python is provided, I directly use the Python subscriber API and make call to the server, return the data in json format. - If Java/C++ are provided, I call the respective launcher script, dump the data to some file. Once the execution is done I read the file and return the data in Python format.

While all the subscriber API ideally should return same data, for testing purpose I need to expose all the versions.

But having the language option doesn't seem to be clean way of doing this. What would be the neat way of doing this ?

One option I thought of is, the default Handle API would work with python only and the for java/c++, I'll create two different handles JavaHandle, CPPHandle and use it.

Aucun commentaire:

Enregistrer un commentaire