userver: storages::redis::CommandControl Struct Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
storages::redis::CommandControl Struct Reference

#include <userver/storages/redis/command_control.hpp>

Detailed Description

Redis command execution options.

Examples
samples/redis_service/main.cpp.

Definition at line 76 of file command_control.hpp.

Public Types

enum class  Strategy {
  kDefault ,
  kEveryDc ,
  kLocalDcConductor ,
  kNearestServerPing
}
 

Public Member Functions

constexpr CommandControl (const std::optional< std::chrono::milliseconds > &timeout_single, const std::optional< std::chrono::milliseconds > &timeout_all, const std::optional< size_t > &max_retries) noexcept
 
auto operator<=> (const CommandControl &) const =default
 
CommandControl MergeWith (const CommandControl &b) const
 
CommandControl MergeWith (const testsuite::RedisControl &) const
 
CommandControl MergeWith (RetryNilFromMaster) const
 
std::string ToString () const
 

Public Attributes

std::optional< std::chrono::milliseconds > timeout_single
 Timeout for a single attempt to execute command.
 
std::optional< std::chrono::milliseconds > timeout_all
 Command execution timeout, including retries.
 
std::optional< std::size_t > max_retries
 The maximum number of retries while executing command.
 
std::optional< Strategystrategy {}
 Server instance selection strategy.
 
std::optional< std::size_t > best_dc_count {}
 How many nearest DCs to use.
 
std::optional< bool > force_request_to_master {}
 Force execution on master node.
 
std::optional< std::chrono::milliseconds > max_ping_latency {}
 Server latency limit.
 
std::optional< bool > allow_reads_from_master {}
 
std::optional< bool > account_in_statistics {}
 Controls if the command execution accounted in statistics.
 
std::optional< std::size_t > force_shard_idx {}
 If set, force execution on specific shard.
 
std::optional< std::size_t > chunk_size {}
 Split execution of multi-key commands (i.e., MGET) to multiple requests.
 
std::optional< ServerIdforce_server_id {}
 
bool force_retries_to_master_on_nil_reply {false}
 If set, command retries are directed to the master instance.
 
size_t retry_counter {0}
 

Member Enumeration Documentation

◆ Strategy

Enumerator
kDefault 

Same as kEveryDc.

kEveryDc 

Send ~1/N requests to an instance with ping N ms.

kLocalDcConductor 

Send requests to Redis instances located in local DC (by Conductor info)

kNearestServerPing 

Send requests to 'best_dc_count' Redis instances with the min ping.

Definition at line 77 of file command_control.hpp.

Constructor & Destructor Documentation

◆ CommandControl()

storages::redis::CommandControl::CommandControl ( const std::optional< std::chrono::milliseconds > & timeout_single,
const std::optional< std::chrono::milliseconds > & timeout_all,
const std::optional< size_t > & max_retries )
inlineconstexprnoexcept

Definition at line 139 of file command_control.hpp.

Member Data Documentation

◆ account_in_statistics

std::optional<bool> storages::redis::CommandControl::account_in_statistics {}

Controls if the command execution accounted in statistics.

Definition at line 117 of file command_control.hpp.

◆ allow_reads_from_master

std::optional<bool> storages::redis::CommandControl::allow_reads_from_master {}

Allow execution of readonly commands on master node along with replica nodes to facilitate load distribution

Definition at line 114 of file command_control.hpp.

◆ best_dc_count

std::optional<std::size_t> storages::redis::CommandControl::best_dc_count {}

How many nearest DCs to use.

Definition at line 104 of file command_control.hpp.

◆ chunk_size

std::optional<std::size_t> storages::redis::CommandControl::chunk_size {}

Split execution of multi-key commands (i.e., MGET) to multiple requests.

Definition at line 123 of file command_control.hpp.

◆ force_request_to_master

std::optional<bool> storages::redis::CommandControl::force_request_to_master {}

Force execution on master node.

Definition at line 107 of file command_control.hpp.

◆ force_retries_to_master_on_nil_reply

bool storages::redis::CommandControl::force_retries_to_master_on_nil_reply {false}

If set, command retries are directed to the master instance.

Definition at line 131 of file command_control.hpp.

◆ force_server_id

std::optional<ServerId> storages::redis::CommandControl::force_server_id {}

If set, the user wants a specific Redis instance to handle the command. Sentinel may not redirect the command to other instances. strategy is ignored.

Definition at line 128 of file command_control.hpp.

◆ force_shard_idx

std::optional<std::size_t> storages::redis::CommandControl::force_shard_idx {}

If set, force execution on specific shard.

Definition at line 120 of file command_control.hpp.

◆ max_ping_latency

std::optional<std::chrono::milliseconds> storages::redis::CommandControl::max_ping_latency {}

Server latency limit.

Definition at line 110 of file command_control.hpp.

◆ max_retries

std::optional<std::size_t> storages::redis::CommandControl::max_retries

The maximum number of retries while executing command.

Definition at line 98 of file command_control.hpp.

◆ retry_counter

size_t storages::redis::CommandControl::retry_counter {0}

Need to be set to if you do manual retries and want retry budget to work. If set value other than 0 then request treated as retry. 0 - original request, 1 - first retry, 2 - second and so on

Definition at line 136 of file command_control.hpp.

◆ strategy

std::optional<Strategy> storages::redis::CommandControl::strategy {}

Server instance selection strategy.

Definition at line 101 of file command_control.hpp.

◆ timeout_all

std::optional<std::chrono::milliseconds> storages::redis::CommandControl::timeout_all

Command execution timeout, including retries.

Definition at line 95 of file command_control.hpp.

◆ timeout_single

std::optional<std::chrono::milliseconds> storages::redis::CommandControl::timeout_single

Timeout for a single attempt to execute command.

Definition at line 92 of file command_control.hpp.


The documentation for this struct was generated from the following file: