Completely rework return values from storage operations

This commit is contained in:
Tim Wojtulewicz 2025-02-24 14:37:11 -07:00
parent 8ddda016ff
commit 9ed3e33f97
50 changed files with 859 additions and 586 deletions

View file

@ -27,7 +27,7 @@ public:
class Manager final : public plugin::ComponentManager<Component> {
public:
Manager();
~Manager() = default;
~Manager();
/**
* Initialization of the manager. This is called late during Zeek's
@ -36,8 +36,8 @@ public:
void InitPostScript();
/**
* Instantiates a new backend object. The backend will be in a closed state, and OpenBackend()
* will need to be called to fully initialize it.
* Instantiates a new backend object. The backend will be in a closed state,
* and OpenBackend() will need to be called to fully initialize it.
*
* @param type The tag for the type of backend being opened.
* @return A std::expected containing either a valid BackendPtr with the
@ -56,16 +56,22 @@ public:
* validation of types.
* @param val_type The script-side type of the values stored in the backend. Used for
* validation of types and conversion during retrieval.
* @return An optional value potentially containing an error string if needed. Will be
* unset if the operation succeeded.
* @param cb An optional callback object if being called via an async context.
* @return A struct describing the result of the operation, containing a code, an
* optional error string, and a ValPtr for operations that return values.
*/
ErrorResult OpenBackend(BackendPtr backend, RecordValPtr options, TypePtr key_type, TypePtr val_type,
OpenResultCallback* cb = nullptr);
OperationResult OpenBackend(BackendPtr backend, RecordValPtr options, TypePtr key_type, TypePtr val_type,
OpenResultCallback* cb = nullptr);
/**
* Closes a storage backend.
*
* @param backend A pointer to the backend being closed.
* @param cb An optional callback object if being called via an async context.
* @return A struct describing the result of the operation, containing a code, an
* optional error string, and a ValPtr for operations that return values.
*/
ErrorResult CloseBackend(BackendPtr backend, ErrorResultCallback* cb = nullptr);
OperationResult CloseBackend(BackendPtr backend, OperationResultCallback* cb = nullptr);
void Expire();