Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:24

0001 /* Copyright (c) 2018-2024 Marcelo Zimbres Silva (mzimbres@gmail.com)
0002  *
0003  * Distributed under the Boost Software License, Version 1.0. (See
0004  * accompanying file LICENSE.txt)
0005  */
0006 
0007 #ifndef BOOST_REDIS_CONFIG_HPP
0008 #define BOOST_REDIS_CONFIG_HPP
0009 
0010 #include <string>
0011 #include <chrono>
0012 #include <optional>
0013 
0014 namespace boost::redis
0015 {
0016 
0017 /** @brief Address of a Redis server
0018  *  @ingroup high-level-api
0019  */
0020 struct address {
0021    /// Redis host.
0022    std::string host = "127.0.0.1";
0023    /// Redis port.
0024    std::string port = "6379";
0025 };
0026 
0027 /** @brief Configure parameters used by the connection classes
0028  *  @ingroup high-level-api
0029  */
0030 struct config {
0031    /// Uses SSL instead of a plain connection.
0032    bool use_ssl = false;
0033 
0034    /// Address of the Redis server.
0035    address addr = address{"127.0.0.1", "6379"};
0036 
0037    /** @brief Username passed to the
0038     * [HELLO](https://redis.io/commands/hello/) command.  If left
0039     * empty `HELLO` will be sent without authentication parameters.
0040     */
0041    std::string username = "default";
0042 
0043    /** @brief Password passed to the
0044     * [HELLO](https://redis.io/commands/hello/) command.  If left
0045     * empty `HELLO` will be sent without authentication parameters.
0046     */
0047    std::string password;
0048 
0049    /// Client name parameter of the [HELLO](https://redis.io/commands/hello/) command.
0050    std::string clientname = "Boost.Redis";
0051 
0052    /// Database that will be passed to the [SELECT](https://redis.io/commands/hello/) command.
0053    std::optional<int> database_index = 0;
0054 
0055    /// Message used by the health-checker in `boost::redis::connection::async_run`.
0056    std::string health_check_id = "Boost.Redis";
0057 
0058    /// Logger prefix, see `boost::redis::logger`.
0059    std::string log_prefix = "(Boost.Redis) ";
0060 
0061    /// Time the resolve operation is allowed to last.
0062    std::chrono::steady_clock::duration resolve_timeout = std::chrono::seconds{10};
0063 
0064    /// Time the connect operation is allowed to last.
0065    std::chrono::steady_clock::duration connect_timeout = std::chrono::seconds{10};
0066 
0067    /// Time the SSL handshake operation is allowed to last.
0068    std::chrono::steady_clock::duration ssl_handshake_timeout = std::chrono::seconds{10};
0069 
0070    /** Health checks interval.  
0071     *  
0072     *  To disable health-checks pass zero as duration.
0073     */
0074    std::chrono::steady_clock::duration health_check_interval = std::chrono::seconds{2};
0075 
0076    /** @brief Time waited before trying a reconnection.
0077     *  
0078     *  To disable reconnection pass zero as duration.
0079     */
0080    std::chrono::steady_clock::duration reconnect_wait_interval = std::chrono::seconds{1};
0081 };
0082 
0083 } // boost::redis
0084 
0085 #endif // BOOST_REDIS_CONFIG_HPP