Implement Storage::backend_opened and Storage::backend_lost events

This commit is contained in:
Tim Wojtulewicz 2025-03-03 18:19:52 -07:00
parent a99a13dc4c
commit cc7b2dc890
10 changed files with 117 additions and 15 deletions

View file

@ -114,10 +114,15 @@ public:
*/
virtual void Poll() {}
const RecordValPtr& Options() const { return backend_options; }
protected:
// Allow the manager to call Open/Close.
friend class storage::Manager;
// Allow OpenResultCallback to call EnqueueConnectionEstablished.
friend class storage::OpenResultCallback;
/**
* Constructor
*
@ -183,10 +188,24 @@ protected:
*/
virtual void Expire() {}
/**
* Enqueues the Storage::backend_opened event. This is called automatically
* when an OpenResultCallback is completed successfully.
*/
void EnqueueBackendOpened();
/**
* Enqueues the Storage::backend_lost event with an optional reason
* string. This should be called by the backends whenever they lose their
* connection.
*/
void EnqueueBackendLost(std::string_view reason);
void CompleteCallback(ResultCallback* cb, const OperationResult& data) const;
TypePtr key_type;
TypePtr val_type;
RecordValPtr backend_options;
std::string tag;