mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add operation_timeout and command_timeout storage backend options
This commit is contained in:
parent
507974a1d8
commit
824b91216f
5 changed files with 22 additions and 6 deletions
|
@ -10,6 +10,17 @@ export {
|
|||
type BackendOptions: record {
|
||||
## The serializer used for converting Zeek data.
|
||||
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
|
||||
|
|
|
@ -262,7 +262,8 @@ OperationResult Redis::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
|||
opt.options |= REDIS_OPT_PREFER_IPV4;
|
||||
opt.options |= REDIS_OPT_NOAUTOFREEREPLIES;
|
||||
|
||||
struct timeval timeout = {5, 0};
|
||||
auto connect_timeout_opt = options->GetField<IntervalVal>("connect_timeout")->Get();
|
||||
struct timeval timeout = util::double_to_timeval(connect_timeout_opt);
|
||||
opt.connect_timeout = &timeout;
|
||||
|
||||
// The connection request below should be operation #1.
|
||||
|
@ -300,6 +301,10 @@ OperationResult Redis::DoOpen(OpenResultCallback* cb, RecordValPtr options) {
|
|||
redisAsyncSetConnectCallback(async_ctx, redisOnConnect);
|
||||
redisAsyncSetDisconnectCallback(async_ctx, redisOnDisconnect);
|
||||
|
||||
auto op_timeout_opt = options->GetField<IntervalVal>("operation_timeout")->Get();
|
||||
struct timeval op_timeout = util::double_to_timeval(op_timeout_opt);
|
||||
redisAsyncSetTimeout(async_ctx, op_timeout);
|
||||
|
||||
// redisAsyncSetConnectCallback sets the flag in the redisPollEvent for writing
|
||||
// so we can add this to our loop as well.
|
||||
zeek::iosource_mgr->RegisterFd(async_ctx->c.fd, this, zeek::iosource::IOSource::WRITE);
|
||||
|
|
|
@ -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::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
|
||||
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_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
|
||||
|
|
|
@ -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::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
|
||||
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_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
|
||||
|
|
|
@ -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::STORAGE_BACKEND_SQLITE, [serializer=Storage::STORAGE_SERIALIZER_JSON, sqlite=[database_path=test.sqlite, table_name=testing, tuning_params={
|
||||
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={
|
||||
[synchronous] = normal,
|
||||
[temp_store] = memory,
|
||||
[journal_mode] = WAL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue