YR_RECOVER#
-
YR_RECOVER(...)#
Users can use this interface to perform data recovery operations.
Functions to be executed during instance recovery must be decorated with YR_RECOVER. This macro is used to decorate user-defined state member functions within actors executing in the cloud. Functions decorated with YR_RECOVER can utilize Yuanrong interfaces. These functions will be executed in the following scenarios: during runtime recovery requests to restore instances.
class Counter { public: int count; int recoverFlag = 0; Counter() {} explicit Counter(int init) : count(init) {} static Counter *FactoryCreate(int init) { return new Counter(init); } int SaveState(); int LoadState(); void Recover(); }; int Counter::SaveState() { YR::SaveState(); return count; } int Counter::LoadState() { YR::LoadState(); return count; } YR_INVOKE(&Counter::SaveState, &Counter::LoadState); void Counter::Recover() { std::cout << "recover" << std::endl; recoverFlag++; } YR_RECOVER(&Counter::Recover);
- Throws Exception:
If a function is detected to be registered multiple times, the program will exit with an error message.