RpcController.h 619 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef NET_RPC_CONTROLLER_H
  2. #define NET_RPC_CONTROLLER_H
  3. #include <google/protobuf/service.h>
  4. namespace Hainan {
  5. class RpcController: public google::protobuf::RpcController
  6. {
  7. private:
  8. bool failed;
  9. std::string reason;
  10. bool canceled;
  11. public:
  12. RpcController();
  13. ~RpcController();
  14. // client
  15. virtual void Reset();
  16. virtual bool Failed() const;
  17. virtual std::string ErrorText() const;
  18. virtual void StartCancel();
  19. // server
  20. virtual void SetFailed(const string& reason);
  21. virtual bool IsCanceled() const;
  22. virtual void NotifyOnCancel(Closure* callback);
  23. };
  24. } // namespace Hainan
  25. #endif // NET_RPC_CONTROLLER_H