- 論壇徽章:
- 24
|
eveson 發(fā)表于 2014-12-11 15:37 ![]()
看了下介紹,感覺(jué)thrift 其實(shí)就實(shí)現(xiàn)了一個(gè)類似于select或者epool的功能,其他沒(méi)做什么,具體的實(shí)現(xiàn)代 ...
還有 RPC 的編碼和解碼也是 thrift 完成的,業(yè)務(wù)邏輯處理當(dāng)然要自己寫了。
- class CalculatorHandler : virtual public CalculatorIf {
- public:
- CalculatorHandler() {
- // Your initialization goes here
- }
- /**
- * A method definition looks like C code. It has a return type, arguments,
- * and optionally a list of exceptions that it may throw. Note that argument
- * lists and exception lists are specified using the exact same syntax as
- * field lists in struct or exception definitions.
- */
- void ping() {
- // Your implementation goes here
- printf("ping\n");
- }
- int32_t add(const int32_t num1, const int32_t num2) {
- // Your implementation goes here
- printf("add\n");
- }
- int32_t calculate(const int32_t logid, const Work& w) {
- // Your implementation goes here
- printf("calculate\n");
- }
- /**
- * This method has a oneway modifier. That means the client only makes
- * a request and does not listen for any response at all. Oneway methods
- * must be void.
- */
- void zip() {
- // Your implementation goes here
- printf("zip\n");
- }
- };
復(fù)制代碼 這個(gè)類是 thrift 生成的,需要程序員實(shí)現(xiàn)各個(gè)服務(wù)函數(shù)的功能,然后 RPC 的編碼和解碼和網(wǎng)絡(luò)通信是 thrift 完成的。
|
|