mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add STORAGE_ prefixes for backends and serializers
This commit is contained in:
parent
9593db1974
commit
cb1ef47a31
24 changed files with 33 additions and 33 deletions
|
@ -9,7 +9,7 @@ export {
|
|||
## to add relevant fields to it.
|
||||
type BackendOptions: record {
|
||||
## The serializer used for converting Zeek data.
|
||||
serializer: Storage::Serializer &default=Storage::JSON;
|
||||
serializer: Storage::Serializer &default=Storage::STORAGE_SERIALIZER_JSON;
|
||||
};
|
||||
|
||||
## Record for passing arguments to :zeek:see:`Storage::Async::put` and
|
||||
|
|
|
@ -14,7 +14,7 @@ BackendComponent::BackendComponent(const std::string& name, factory_callback arg
|
|||
|
||||
void BackendComponent::Initialize() {
|
||||
InitializeTag();
|
||||
storage_mgr->BackendMgr().RegisterComponent(this);
|
||||
storage_mgr->BackendMgr().RegisterComponent(this, "STORAGE_BACKEND_");
|
||||
}
|
||||
|
||||
void BackendComponent::DoDescribe(ODesc* d) const {
|
||||
|
@ -29,7 +29,7 @@ SerializerComponent::SerializerComponent(const std::string& name, factory_callba
|
|||
|
||||
void SerializerComponent::Initialize() {
|
||||
InitializeTag();
|
||||
storage_mgr->SerializerMgr().RegisterComponent(this);
|
||||
storage_mgr->SerializerMgr().RegisterComponent(this, "STORAGE_SERIALIZER_");
|
||||
}
|
||||
|
||||
void SerializerComponent::DoDescribe(ODesc* d) const {
|
||||
|
|
|
@ -10,7 +10,7 @@ get result after erase, [code=Storage::KEY_NOT_FOUND, error_str=<uninitialized>,
|
|||
close result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||
results of trying to use closed handle: get: Storage::NOT_CONNECTED, put: Storage::NOT_CONNECTED, erase: Storage::NOT_CONNECTED
|
||||
|
||||
open result 2, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGEDUMMY: open_fail was set to true, returning error, value=<opaque of BackendHandleVal>]
|
||||
open result 2, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGE_BACKEND_STORAGEDUMMY: open_fail was set to true, returning error, value=<opaque of BackendHandleVal>]
|
||||
close result on closed handle, [code=Storage::NOT_CONNECTED, error_str=Backend is closed, value=<uninitialized>]
|
||||
|
||||
open result 3, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
open_result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
||||
Storage::backend_opened, Storage::REDIS, [serializer=Storage::JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]]
|
||||
Storage::backend_lost, Storage::REDIS, [serializer=Storage::JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]], Server closed the connection
|
||||
Storage::backend_opened, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]]
|
||||
Storage::backend_lost, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]], Server closed the connection
|
||||
|
|
|
@ -9,5 +9,5 @@ get result same as originally inserted, T
|
|||
put result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||
get result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=value2345]
|
||||
get result same as overwritten, T
|
||||
Storage::backend_opened, Storage::REDIS, [serializer=Storage::JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]]
|
||||
Storage::backend_lost, Storage::REDIS, [serializer=Storage::JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]], Client disconnected
|
||||
Storage::backend_opened, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]]
|
||||
Storage::backend_lost, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]], Client disconnected
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
Storage::backend_opened, Storage::SQLITE, [serializer=Storage::JSON, sqlite=[database_path=test.sqlite, table_name=testing, tuning_params={
|
||||
Storage::backend_opened, Storage::STORAGE_BACKEND_SQLITE, [serializer=Storage::STORAGE_SERIALIZER_JSON, sqlite=[database_path=test.sqlite, table_name=testing, tuning_params={
|
||||
[synchronous] = normal,
|
||||
[temp_store] = memory,
|
||||
[journal_mode] = WAL
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
Open result, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::SQLITE: SQLite call failed: unable to open database file, value=<opaque of BackendHandleVal>]
|
||||
Open result, [code=Storage::OPERATION_FAILED, error_str=Failed to open backend Storage::STORAGE_BACKEND_SQLITE: SQLite call failed: unable to open database file, value=<opaque of BackendHandleVal>]
|
||||
Open result 2, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
||||
Put result with bad key type, [code=Storage::KEY_TYPE_MISMATCH, error_str=<uninitialized>, value=<uninitialized>]
|
||||
Put result on closed handle, [code=Storage::NOT_CONNECTED, error_str=Backend is closed, value=<uninitialized>]
|
||||
|
|
|
@ -28,7 +28,7 @@ event zeek_init() {
|
|||
local value = "value5678";
|
||||
|
||||
# Basic operation. Open, put, and get the value back.
|
||||
local res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
||||
local res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_STORAGEDUMMY, opts, string, string);
|
||||
print "open result", res;
|
||||
local b = res$value;
|
||||
|
||||
|
@ -63,7 +63,7 @@ event zeek_init() {
|
|||
|
||||
# Test failing to open the handle and test closing an invalid handle.
|
||||
opts$dummy = [$open_fail = T, $timeout_put = F];
|
||||
res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
||||
res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_STORAGEDUMMY, opts, string, string);
|
||||
print "open result 2", res;
|
||||
res = Storage::Sync::close_backend(res$value);
|
||||
print "close result on closed handle", res;
|
||||
|
@ -71,7 +71,7 @@ event zeek_init() {
|
|||
|
||||
# Test timing out an async put request.
|
||||
opts$dummy = [$open_fail = F, $timeout_put = T];
|
||||
res = Storage::Sync::open_backend(Storage::STORAGEDUMMY, opts, string, string);
|
||||
res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_STORAGEDUMMY, opts, string, string);
|
||||
print "open result 3", res;
|
||||
b = res$value;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ event zeek_init() {
|
|||
value[2] = "b";
|
||||
value[3] = "c";
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::SQLITE, opts, Rec, tbl);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, Rec, tbl);
|
||||
print "open result", open_res;
|
||||
local b = open_res$value;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ event zeek_init()
|
|||
|
||||
# Test inserting/retrieving a key/value pair that we know won't be in
|
||||
# the backend yet.
|
||||
local open_res = Storage::Sync::open_backend(Storage::SQLITE, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, string, string);
|
||||
print "open result", open_res;
|
||||
local b = open_res$value;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ event setup_test()
|
|||
local opts : Storage::BackendOptions;
|
||||
opts$sqlite = [$database_path = "storage-test.sqlite", $table_name = "testing"];
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::SQLITE, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, string, string);
|
||||
print "open result", open_res;
|
||||
|
||||
b = open_res$value;
|
||||
|
|
|
@ -18,7 +18,7 @@ event zeek_init() {
|
|||
local value = "value7890";
|
||||
local value2 = "value2345";
|
||||
|
||||
local res = Storage::Sync::open_backend(Storage::SQLITE, opts, str, str);
|
||||
local res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, str, str);
|
||||
print "open result", res;
|
||||
local b = res$value;
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ event zeek_init()
|
|||
local key = "key1234";
|
||||
local value = "value5678";
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
print "open result", open_res;
|
||||
local b = open_res$value;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ event zeek_init()
|
|||
local value = "value5678";
|
||||
|
||||
when [opts, key, value] ( local open_res = Storage::Async::open_backend(
|
||||
Storage::REDIS, opts, string, string) )
|
||||
Storage::STORAGE_BACKEND_REDIS, opts, string, string) )
|
||||
{
|
||||
print "open result", open_res;
|
||||
local b = open_res$value;
|
||||
|
|
|
@ -40,7 +40,7 @@ event zeek_init()
|
|||
opts$redis = [ $server_host="127.0.0.1", $server_port=to_port(getenv(
|
||||
"REDIS_PORT")), $key_prefix="testing" ];
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
backend = open_res$value;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ event Storage::backend_lost(tag: Storage::Backend, config: any, reason: string)
|
|||
event zeek_init()
|
||||
{
|
||||
local opts: Storage::BackendOptions;
|
||||
opts$serializer = Storage::JSON;
|
||||
opts$serializer = Storage::STORAGE_SERIALIZER_JSON;
|
||||
opts$redis = [ $server_host="127.0.0.1", $server_port=to_port(getenv(
|
||||
"REDIS_PORT")), $key_prefix="testing" ];
|
||||
|
||||
local key = "key1234";
|
||||
local value = "value1234";
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
print "open_result", open_res;
|
||||
|
||||
# Kill the redis server so the backend will disconnect and fire the backend_lost event.
|
||||
|
|
|
@ -21,7 +21,7 @@ event zeek_init()
|
|||
local key = "key1234";
|
||||
local value = "value1234";
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
print "open_result", open_res;
|
||||
|
||||
local b = open_res$value;
|
||||
|
|
|
@ -40,7 +40,7 @@ event setup_test()
|
|||
opts$redis = [ $server_host="127.0.0.1", $server_port=to_port(getenv(
|
||||
"REDIS_PORT")), $key_prefix="testing" ];
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
print "open result", open_res;
|
||||
|
||||
b = open_res$value;
|
||||
|
|
|
@ -40,7 +40,7 @@ event setup_test()
|
|||
opts$redis = [ $server_host="127.0.0.1", $server_port=to_port(getenv(
|
||||
"REDIS_PORT")), $key_prefix="testing" ];
|
||||
|
||||
local open_res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
print "open result", open_res;
|
||||
|
||||
b = open_res$value;
|
||||
|
|
|
@ -24,7 +24,7 @@ event Storage::backend_lost(tag: Storage::Backend, config: any, reason: string)
|
|||
event zeek_init()
|
||||
{
|
||||
local opts: Storage::BackendOptions;
|
||||
opts$serializer = Storage::JSON;
|
||||
opts$serializer = Storage::STORAGE_SERIALIZER_JSON;
|
||||
opts$redis = [ $server_host="127.0.0.1", $server_port=to_port(getenv(
|
||||
"REDIS_PORT")), $key_prefix="testing" ];
|
||||
|
||||
|
@ -32,7 +32,7 @@ event zeek_init()
|
|||
local value = "value1234";
|
||||
local value2 = "value2345";
|
||||
|
||||
local res = Storage::Sync::open_backend(Storage::REDIS, opts, string, string);
|
||||
local res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_REDIS, opts, string, string);
|
||||
print "open_result", res;
|
||||
|
||||
local b = res$value;
|
||||
|
|
|
@ -20,7 +20,7 @@ event zeek_init()
|
|||
|
||||
# Test inserting/retrieving a key/value pair that we know won't be in
|
||||
# the backend yet.
|
||||
local open_res = Storage::Sync::open_backend(Storage::SQLITE, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, string, string);
|
||||
print "open result", open_res;
|
||||
|
||||
local b = open_res$value;
|
||||
|
|
|
@ -24,7 +24,7 @@ event zeek_init()
|
|||
# Test inserting/retrieving a key/value pair that we know won't be in
|
||||
# the backend yet.
|
||||
when [opts, key, value] ( local open_res = Storage::Sync::open_backend(
|
||||
Storage::SQLITE, opts, string, string) )
|
||||
Storage::STORAGE_BACKEND_SQLITE, opts, string, string) )
|
||||
{
|
||||
print "open result", open_res;
|
||||
local b = open_res$value;
|
||||
|
|
|
@ -16,7 +16,7 @@ event zeek_init()
|
|||
{
|
||||
# Create a database file in the .tmp directory with a 'testing' table
|
||||
local opts: Storage::BackendOptions;
|
||||
opts$serializer = Storage::JSON;
|
||||
opts$serializer = Storage::STORAGE_SERIALIZER_JSON;
|
||||
opts$sqlite = [ $database_path="test.sqlite", $table_name="testing" ];
|
||||
|
||||
local key = "key1234";
|
||||
|
@ -25,7 +25,7 @@ event zeek_init()
|
|||
# Test inserting/retrieving a key/value pair that we know won't be in
|
||||
# the backend yet.
|
||||
when [opts, key, value] ( local open_res = Storage::Async::open_backend(
|
||||
Storage::SQLITE, opts, string, string) )
|
||||
Storage::STORAGE_BACKEND_SQLITE, opts, string, string) )
|
||||
{
|
||||
print "open result", open_res;
|
||||
local b = open_res$value;
|
||||
|
|
|
@ -14,12 +14,12 @@ event zeek_init() {
|
|||
$table_name = "testing"];
|
||||
|
||||
# This should report an error in .stderr and reporter.log
|
||||
local open_res = Storage::Sync::open_backend(Storage::SQLITE, opts, string, string);
|
||||
local open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, string, string);
|
||||
print "Open result", open_res;
|
||||
|
||||
# Open a valid database file
|
||||
opts$sqlite$database_path = "test.sqlite";
|
||||
open_res = Storage::Sync::open_backend(Storage::SQLITE, opts, string, string);
|
||||
open_res = Storage::Sync::open_backend(Storage::STORAGE_BACKEND_SQLITE, opts, string, string);
|
||||
print "Open result 2", open_res;
|
||||
|
||||
local b = open_res$value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue