Hi Jonathan,

I would like to implement Kaltura server API using thrift.

Great!

[...] add global list of arguments to all requests [...]
such as client library version, client tag, account id,
session id and few more, these arguments could be
added to any request but none of them is required.

Since the Thrift IDL is by design lacking the concept of inheritance, we came up with another solution for our projects.

   // data common to all requests
   struct ApiRequest {
         1 : optional string SessionID
         2 : optional string MsgID
         3 : optional string ApiKey
   }

The first approach could be straightforward like so:

   service Foobarizer {
ProductDetails GetProductDetails( 1 : ApiRequest request, 2: string productID)
   }

For some other reason, we decided to do it slightly different, like so:

   // data for one particular request
   struct GetProductDetails {
1 : required ApiRequest base_ // data common to all requests
         2 : required string ProductID
3 : optional DetailsOfInterest DetailsOfInterest // that's another structure
   }


   service Foobarizer {
ProductDetails GetProductDetails( 1 : GetProductDetails request) throws ( 1: RemotableException rex)
   }

And then we did the same with our responses, which all contain a similar structure field:


   // response base class
   struct ApiResponse {
         1 : optional string SessionID
2 : optional string CorrelationID // the MsgID taken from the request
         3 : optional list<ErrorEntry> WarningsAndErrors
   }

   struct ProductDetails {
1 : required ApiResponse base_ // data common to all requests
       // ... other data as needed ...
   }


So far we made good experiences with that approach, especially as it is easily maintanable and extendable, and the base_ field has a common structure that can be handled in a centralized manner.

Have fun,
JensG


-----Ursprüngliche Nachricht----- From: Jonathan Kanarek
Sent: Tuesday, March 31, 2015 7:58 PM
To: [email protected]
Subject: Global arguments

Hi,
I would like to implement Kaltura server API using thrift.
I couldn't find if and how is it possible to add global list of arguments to all requests. I have list of optional arguments, such as client library version, client tag, account id, session id and few more, these arguments could be added to any request but none of them is required.
How would you define such arguments in the interface?

Thanks,
Tan-Tan.

Reply via email to