Just have your CalculatorServiceHandler inherit from ServiceBaseHandler.

Fb303 example would look like:
class CalculatorHandler : virtual public CalculatorServiceIf, public 
FacebookBase {
}

By inheriting public from FacebookBase you get the base method implementations.


-----Original Message-----
From: David Balatero [mailto:[email protected]] 
Sent: Monday, December 15, 2008 4:25 PM
To: [email protected]
Subject: Defining a base service in thrift?

I want to set up the following type of service structure:

Thrift
---------------------------
service ServiceBase {
  // A generic method to ping if a service is up?
  bool ping(),

  // How long has this service been up?
  i64 uptime()
}

service CalculatorService extends ServiceBase {
  // Adds two ints together.
  int add(int a, int b)
}

I want to implement the ServiceBase methods only once, so that all services can 
be ping()able, and all services can be queried about their uptime(). This way, 
any service under my infrastructure only has to implement its special methods 
(CalculatorService::add(), for example).

However, there doesn't seem to be a clean way for me to provide a base 
implementation with my C++ services, and have the auto-generated 
implementations also inherit from my base implementation.

How have other people solved this problem? I was trying to poke into fb303, but 
I wasn't able to gain any more insight in accomplishing this. Maybe I missed 
something, though? Any help would be appreciated.

Thanks!
David Balatero

Reply via email to