mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move options to redis backend options instead of module-level options
This commit is contained in:
parent
824b91216f
commit
fd10dd015f
6 changed files with 24 additions and 18 deletions
|
@ -10,17 +10,6 @@ export {
|
||||||
type BackendOptions: record {
|
type BackendOptions: record {
|
||||||
## The serializer used for converting Zeek data.
|
## The serializer used for converting Zeek data.
|
||||||
serializer: Storage::Serializer &default=Storage::STORAGE_SERIALIZER_JSON;
|
serializer: Storage::Serializer &default=Storage::STORAGE_SERIALIZER_JSON;
|
||||||
|
|
||||||
## Timeout for connection attempts to the backend. Connection attempts
|
|
||||||
## that exceed this time should return
|
|
||||||
## :zeek:see:`Storage::CONNECTION_FAILED`. Not all backends will support
|
|
||||||
## setting timeouts.
|
|
||||||
connect_timeout: interval &default=5 sec;
|
|
||||||
|
|
||||||
## Timeout for operation requests sent to the backend. Operations that
|
|
||||||
## exceed this time should return :zeek:see:`Storage::TIMEOUT`. Not all
|
|
||||||
## backends will support setting timeouts.
|
|
||||||
operation_timeout: interval &default=5 sec;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
## Record for passing arguments to :zeek:see:`Storage::Async::put` and
|
## Record for passing arguments to :zeek:see:`Storage::Async::put` and
|
||||||
|
|
|
@ -5,6 +5,14 @@
|
||||||
module Storage::Backend::Redis;
|
module Storage::Backend::Redis;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
## Default value for connection attempt timeouts. This can be overridden
|
||||||
|
## per-connection with the ``connect_timeout`` backend option.
|
||||||
|
const default_connect_timeout: interval = 5 secs &redef;
|
||||||
|
|
||||||
|
## Default value for operation timeouts. This can be overridden per-connection
|
||||||
|
## with the ``operation_timeout`` backend option.
|
||||||
|
const default_operation_timeout: interval = 5 secs &redef;
|
||||||
|
|
||||||
## Options record for the built-in Redis backend.
|
## Options record for the built-in Redis backend.
|
||||||
type Options: record {
|
type Options: record {
|
||||||
# Address or hostname of the server.
|
# Address or hostname of the server.
|
||||||
|
@ -22,6 +30,15 @@ export {
|
||||||
# same server. Defaults to an empty string, but preferably should be set
|
# same server. Defaults to an empty string, but preferably should be set
|
||||||
# to a unique value per Redis backend opened.
|
# to a unique value per Redis backend opened.
|
||||||
key_prefix: string &default="";
|
key_prefix: string &default="";
|
||||||
|
|
||||||
|
## Timeout for connection attempts to the backend. Connection attempts
|
||||||
|
## that exceed this time will return
|
||||||
|
## :zeek:see:`Storage::CONNECTION_FAILED`.
|
||||||
|
connect_timeout: interval &default=default_connect_timeout;
|
||||||
|
|
||||||
|
## Timeout for operation requests sent to the backend. Operations that
|
||||||
|
## exceed this time will return :zeek:see:`Storage::TIMEOUT`.
|
||||||
|
operation_timeout: interval &default=default_operation_timeout;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ OperationResult Redis::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
||||||
opt.options |= REDIS_OPT_PREFER_IPV4;
|
opt.options |= REDIS_OPT_PREFER_IPV4;
|
||||||
opt.options |= REDIS_OPT_NOAUTOFREEREPLIES;
|
opt.options |= REDIS_OPT_NOAUTOFREEREPLIES;
|
||||||
|
|
||||||
auto connect_timeout_opt = options->GetField<IntervalVal>("connect_timeout")->Get();
|
auto connect_timeout_opt = backend_options->GetField<IntervalVal>("connect_timeout")->Get();
|
||||||
struct timeval timeout = util::double_to_timeval(connect_timeout_opt);
|
struct timeval timeout = util::double_to_timeval(connect_timeout_opt);
|
||||||
opt.connect_timeout = &timeout;
|
opt.connect_timeout = &timeout;
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ OperationResult Redis::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
||||||
redisAsyncSetConnectCallback(async_ctx, redisOnConnect);
|
redisAsyncSetConnectCallback(async_ctx, redisOnConnect);
|
||||||
redisAsyncSetDisconnectCallback(async_ctx, redisOnDisconnect);
|
redisAsyncSetDisconnectCallback(async_ctx, redisOnDisconnect);
|
||||||
|
|
||||||
auto op_timeout_opt = options->GetField<IntervalVal>("operation_timeout")->Get();
|
auto op_timeout_opt = backend_options->GetField<IntervalVal>("operation_timeout")->Get();
|
||||||
struct timeval op_timeout = util::double_to_timeval(op_timeout_opt);
|
struct timeval op_timeout = util::double_to_timeval(op_timeout_opt);
|
||||||
redisAsyncSetTimeout(async_ctx, op_timeout);
|
redisAsyncSetTimeout(async_ctx, op_timeout);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### 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>]
|
open_result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<opaque of BackendHandleVal>]
|
||||||
Storage::backend_opened, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, connect_timeout=5.0 secs, operation_timeout=5.0 secs, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]]
|
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, connect_timeout=5.0 secs, operation_timeout=5.0 secs]]
|
||||||
Storage::backend_lost, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, connect_timeout=5.0 secs, operation_timeout=5.0 secs, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]], Server closed the connection
|
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, connect_timeout=5.0 secs, operation_timeout=5.0 secs]], 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>]
|
put result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=<uninitialized>]
|
||||||
get result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=value2345]
|
get result, [code=Storage::SUCCESS, error_str=<uninitialized>, value=value2345]
|
||||||
get result same as overwritten, T
|
get result same as overwritten, T
|
||||||
Storage::backend_opened, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, connect_timeout=5.0 secs, operation_timeout=5.0 secs, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]]
|
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, connect_timeout=5.0 secs, operation_timeout=5.0 secs]]
|
||||||
Storage::backend_lost, Storage::STORAGE_BACKEND_REDIS, [serializer=Storage::STORAGE_SERIALIZER_JSON, connect_timeout=5.0 secs, operation_timeout=5.0 secs, redis=[server_host=127.0.0.1, server_port=xxxx/tcp, server_unix_socket=<uninitialized>, key_prefix=testing]], Client disconnected
|
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, connect_timeout=5.0 secs, operation_timeout=5.0 secs]], 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.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
Storage::backend_opened, Storage::STORAGE_BACKEND_SQLITE, [serializer=Storage::STORAGE_SERIALIZER_JSON, connect_timeout=5.0 secs, operation_timeout=5.0 secs, 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,
|
[synchronous] = normal,
|
||||||
[temp_store] = memory,
|
[temp_store] = memory,
|
||||||
[journal_mode] = WAL
|
[journal_mode] = WAL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue