Ground work for pluggable storage serializers

This commit is contained in:
Tim Wojtulewicz 2025-04-01 16:14:35 -07:00
parent faac36f4cd
commit e545fe8256
21 changed files with 235 additions and 57 deletions

View file

@ -25,9 +25,8 @@ export {
## Returns: A record containing the status of the operation, and either an error
## string on failure or a value on success. The value returned here will
## be an ``opaque of BackendHandle``.
global open_backend: function(btype: Storage::Backend,
options: Storage::BackendOptions, key_type: any, val_type: any)
: Storage::OperationResult;
global open_backend: function(btype: Storage::Backend, options: Storage::BackendOptions,
key_type: any, val_type: any): Storage::OperationResult;
## Closes an existing backend connection asynchronously. This method must be
## called via a :zeek:see:`when` condition or an error will be returned.

View file

@ -7,23 +7,26 @@ export {
## :zeek:see:`Storage::Async::open_backend` and
## :zeek:see:`Storage::Sync::open_backend`. Backend plugins can redef this record
## to add relevant fields to it.
type BackendOptions: record { };
type BackendOptions: record {
## The serializer used for converting Zeek data.
serializer: Storage::Serializer &default=Storage::JSON;
};
## Record for passing arguments to :zeek:see:`Storage::Async::put` and
## :zeek:see:`Storage::Sync::put`.
type PutArgs: record {
# The key to store the value under.
## The key to store the value under.
key: any;
# The value to store associated with the key.
## The value to store associated with the key.
value: any;
# Indicates whether this value should overwrite an existing entry for the
# key.
## Indicates whether this value should overwrite an existing entry for the
## key.
overwrite: bool &default=T;
# An interval of time until the entry is automatically removed from the
# backend.
## An interval of time until the entry is automatically removed from the
## backend.
expire_time: interval &default=0sec;
};
}

View file

@ -23,9 +23,8 @@ export {
## Returns: A record containing the status of the operation, and either an error
## string on failure or a value on success. The value returned here will
## be an ``opaque of BackendHandle``.
global open_backend: function(btype: Storage::Backend,
options: Storage::BackendOptions, key_type: any, val_type: any)
: Storage::OperationResult;
global open_backend: function(btype: Storage::Backend, options: Storage::BackendOptions,
key_type: any, val_type: any): Storage::OperationResult;
## Closes an existing backend connection.
##