runner.ipp 884 B

123456789101112131415161718192021222324252627
  1. /* Copyright (c) 2018-2024 Marcelo Zimbres Silva ([email protected])
  2. *
  3. * Distributed under the Boost Software License, Version 1.0. (See
  4. * accompanying file LICENSE.txt)
  5. */
  6. #include <boost/redis/detail/runner.hpp>
  7. namespace boost::redis::detail
  8. {
  9. void push_hello(config const& cfg, request& req)
  10. {
  11. if (!cfg.username.empty() && !cfg.password.empty() && !cfg.clientname.empty())
  12. req.push("HELLO", "3", "AUTH", cfg.username, cfg.password, "SETNAME", cfg.clientname);
  13. else if (cfg.password.empty() && cfg.clientname.empty())
  14. req.push("HELLO", "3");
  15. else if (cfg.clientname.empty())
  16. req.push("HELLO", "3", "AUTH", cfg.username, cfg.password);
  17. else
  18. req.push("HELLO", "3", "SETNAME", cfg.clientname);
  19. if (cfg.database_index && cfg.database_index.value() != 0)
  20. req.push("SELECT", cfg.database_index.value());
  21. }
  22. } // boost::redis::detail