Remove unused cnf parameter in client_service

Summary: related to T13709

Reviewers: ivica

Reviewed By: ivica

Subscribers: miljen, iljazovic

Differential Revision: https://repo.mireo.local/D27895
This commit is contained in:
Korina Šimičević
2024-02-14 07:59:27 +01:00
parent 2b686dd6cb
commit cfa2b76176
30 changed files with 61 additions and 67 deletions

View File

@@ -67,7 +67,7 @@ int main() {
boost::asio::io_context ioc;
using client_type = async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("<your-client-id>", "<client-username>", "<client-pwd>")
.brokers("<your-mqtt-broker>", 1883)

View File

@@ -58,7 +58,7 @@ The following example illustrates a simple scenario of configuring a Client and
boost::asio::io_context ioc;
using client_type = async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("<your-client-id>", "<client-username>", "<client-pwd>")
.brokers("<your-mqtt-broker>", 1883)

View File

@@ -103,7 +103,7 @@ int main(int argc, char** argv) {
asio::io_context ioc;
// Make an instance of mqtt_client. Establish a TCP connection with the Broker.
client_type c(ioc.get_executor(), "");
client_type c(ioc.get_executor());
c.credentials("test-client", "username", "password")
.brokers("mqtt.broker", 1883)

View File

@@ -161,7 +161,7 @@ int main(int argc, char** argv) {
asio::io_context ioc;
// Make an instance of mqtt_client. Establish a TCP connection with the Broker.
client_type c(ioc.get_executor(), "");
client_type c(ioc.get_executor());
c.credentials("test-client", "username", "password")
.brokers("mqtt.broker", 1883)

View File

@@ -92,7 +92,7 @@ int main(int argc, char** argv) {
threads.reserve(thread_num - 1);
// Make an instance of mqtt_client. Establish a TCP connection with the Broker.
client_type c(ioc.get_executor(), "");
client_type c(ioc.get_executor());
c.credentials("test-client", "", "")
.brokers("mqtt.broker", 1883)

View File

@@ -12,7 +12,7 @@ void tcp_setup() {
boost::asio::io_context ioc;
// Use ``__TCP_SOCKET__`` as the underlying stream.
async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket> client(ioc, "");
async_mqtt5::mqtt_client<boost::asio::ip::tcp::socket> client(ioc);
}
//]
@@ -77,7 +77,7 @@ void ssl_setup() {
async_mqtt5::mqtt_client<
boost::asio::ssl::stream<boost::asio::ip::tcp::socket>,
boost::asio::ssl::context
> client(ioc, "", std::move(context));
> client(ioc, std::move(context));
}
//]
@@ -96,7 +96,7 @@ void websocket_tcp_setup() {
// Use ``[beastreflink boost__beast__websocket__stream websocket::stream<__TCP_SOCKET__>]`` as the underlying stream.
async_mqtt5::mqtt_client<
boost::beast::websocket::stream<boost::asio::ip::tcp::socket>
> client(ioc, "");
> client(ioc);
}
//]
@@ -167,7 +167,7 @@ void websocket_tls_setup() {
async_mqtt5::mqtt_client<
boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>>,
boost::asio::ssl::context
> client(ioc, "", std::move(context));
> client(ioc, std::move(context));
}
//]

View File

@@ -65,7 +65,7 @@ void publish_qos0_openssl_tls() {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-qos0-openssl-tls", "", "")
.brokers("emqtt.mireo.local", 8883)
@@ -98,7 +98,7 @@ void publish_qos1_openssl_tls() {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-qos1-openssl-tls", "", "")
.brokers("emqtt.mireo.local", 8883)
@@ -133,7 +133,7 @@ void publish_qos2_openssl_tls() {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-qos2-openssl-tls", "", "")
.brokers("emqtt.mireo.local", 8883)
@@ -168,7 +168,7 @@ void subscribe_and_receive_openssl_tls(int num_receive) {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-subscriber-openssl-tls", "", "")
.brokers("emqtt.mireo.local", 8883)

View File

@@ -16,7 +16,7 @@ namespace asio = boost::asio;
asio::awaitable<void> client_publisher(asio::io_context& ioc) {
// Initialise the Client, establish connection to the Broker over TCP.
async_mqtt5::mqtt_client<asio::ip::tcp::socket> client(ioc, "");
async_mqtt5::mqtt_client<asio::ip::tcp::socket> client(ioc);
// Configure the Client.
// It is mandatory to call brokers() and async_run() to configure the Brokers to connect to and start the Client.

View File

@@ -16,7 +16,7 @@ namespace asio = boost::asio;
asio::awaitable<void> client_receiver(asio::io_context& ioc) {
// Initialise the Client, establish connection to the Broker over TCP.
async_mqtt5::mqtt_client<asio::ip::tcp::socket> client(ioc, "");
async_mqtt5::mqtt_client<asio::ip::tcp::socket> client(ioc);
// Configure the Client.
// It is mandatory to call brokers() and async_run() to configure the Brokers to connect to and start the Client.

View File

@@ -15,7 +15,7 @@ void publish_qos0_tcp() {
using stream_type = asio::ip::tcp::socket;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
connect_props props;
props[prop::maximum_packet_size] = 1024;
@@ -47,7 +47,7 @@ void publish_qos1_tcp() {
using stream_type = asio::ip::tcp::socket;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-qos1-tcp", "", "")
.brokers("emqtt.mireo.local", 1883)
@@ -74,7 +74,7 @@ void publish_qos2_tcp() {
using stream_type = asio::ip::tcp::socket;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-qos2-tcp", "", "")
.brokers("emqtt.mireo.local", 1883)
@@ -102,7 +102,7 @@ void subscribe_and_receive_tcp(int num_receive) {
using stream_type = asio::ip::tcp::socket;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-subscriber-tcp", "", "")
.brokers("emqtt.mireo.local", 1883)

View File

@@ -20,7 +20,7 @@ void publish_qos0_websocket_tcp() {
>;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-qos0-websocket-tcp", "", "")
.brokers("emqtt.mireo.local/mqtt", 8083)
@@ -50,7 +50,7 @@ void publish_qos1_websocket_tcp() {
>;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-qos1-websocket-tcp", "", "")
.brokers("emqtt.mireo.local/mqtt", 8083)
@@ -81,7 +81,7 @@ void publish_qos2_websocket_tcp() {
>;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-qos2-websocket-tcp", "", "")
.brokers("emqtt.mireo.local/mqtt", 8083)
@@ -113,7 +113,7 @@ void subscribe_and_receive_websocket_tcp(int num_receive) {
>;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.credentials("test-subscriber-websocket-tcp", "", "")
.brokers("emqtt.mireo.local/mqtt", 8083)

View File

@@ -80,7 +80,7 @@ void publish_qos0_websocket_tls() {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-qos0-websocket-tls", "", "")
.brokers("emqtt.mireo.local/mqtt", 8884)
@@ -115,7 +115,7 @@ void publish_qos1_websocket_tls() {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-qos1-websocket-tls", "", "")
.brokers("emqtt.mireo.local/mqtt", 8884)
@@ -151,7 +151,7 @@ void publish_qos2_websocket_tls() {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-qos2-websocket-tls", "", "")
.brokers("emqtt.mireo.local/mqtt", 8884)
@@ -188,7 +188,7 @@ void subscribe_and_receive_websocket_tls(int num_receive) {
tls_context.set_verify_mode(asio::ssl::verify_peer);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.credentials("test-subscriber-websocket-tls", "", "")
.brokers("emqtt.mireo.local/mqtt", 8884)

View File

@@ -254,7 +254,6 @@ public:
client_service(
const executor_type& ex,
const std::string& /* cnf */,
tls_context_type tls_context = {}
) :
_executor(ex),

View File

@@ -54,16 +54,14 @@ public:
* \brief Constructs a Client with given parameters.
*
* \param ex An executor that will be associated with the Client.
* \param cnf
* \param tls_context A context object used in TLS/SLL connection.
*/
explicit mqtt_client(
const executor_type& ex,
const std::string& cnf,
TlsContext tls_context = {}
) :
_impl(std::make_shared<client_service_type>(
ex, cnf, std::move(tls_context)
ex, std::move(tls_context)
))
{}
@@ -72,7 +70,6 @@ public:
*
* \tparam \__ExecutionContext\__ Type of a concrete execution context.
* \param context Execution context whose executor will be associated with the Client.
* \param cnf
* \param tls_context A context object used in TLS/SLL connection.
*
* \par Precondition
@@ -89,10 +86,9 @@ public:
>
explicit mqtt_client(
ExecutionContext& context,
const std::string& cnf,
TlsContext tls_context = {}
) :
mqtt_client(context.get_executor(), cnf, std::move(tls_context))
mqtt_client(context.get_executor(), std::move(tls_context))
{}
/**

View File

@@ -26,11 +26,11 @@ class test_service : public async_mqtt5::detail::client_service<StreamType, TlsC
connack_props _test_props;
public:
test_service(const asio::any_io_executor ex)
: base(ex, {}), _ex(ex)
: base(ex), _ex(ex)
{}
test_service(const asio::any_io_executor ex, connack_props props)
: base(ex, {}), _ex(ex), _test_props(std::move(props))
: base(ex), _ex(ex), _test_props(std::move(props))
{}
template <typename BufferType, typename CompletionToken>
@@ -67,8 +67,8 @@ template <
>
class overrun_client : public async_mqtt5::detail::client_service<StreamType, TlsContext> {
public:
overrun_client(const asio::any_io_executor& ex, const std::string& cnf) :
async_mqtt5::detail::client_service<StreamType, TlsContext>(ex, cnf)
overrun_client(const asio::any_io_executor& ex) :
async_mqtt5::detail::client_service<StreamType, TlsContext>(ex)
{}
uint16_t allocate_pid() {

View File

@@ -77,7 +77,7 @@ BOOST_FIXTURE_TEST_CASE(ordering_after_reconnect, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);
@@ -160,7 +160,7 @@ BOOST_FIXTURE_TEST_CASE(throttling, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1")
.async_run(asio::detached);
@@ -218,7 +218,7 @@ BOOST_FIXTURE_TEST_CASE(prioritize_disconnect, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);

View File

@@ -154,7 +154,7 @@ void run_cancel_op_test() {
asio::io_context ioc;
asio::cancellation_signal signal;
client_type c(ioc, "");
client_type c(ioc);
c.brokers("127.0.0.1");
setup_cancel_op_test_case<op_type>(c, signal, handlers_called);
@@ -271,7 +271,7 @@ BOOST_FIXTURE_TEST_CASE(rerunning_the_client, shared_test_data) {
co_spawn(ioc,
[&]() -> asio::awaitable<void> {
mqtt_client<test::test_stream> c(ioc, "");
mqtt_client<test::test_stream> c(ioc);
c.brokers("127.0.0.1,127.0.0.1", 1883) // to avoid reconnect backoff
.async_run(asio::detached);

View File

@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(tcp_client_check) {
using stream_type = asio::ip::tcp::socket;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.brokers("broker.hivemq.com", 1883)
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(websocket_tcp_client_check) {
>;
using client_type = mqtt_client<stream_type>;
client_type c(ioc, "");
client_type c(ioc);
c.brokers("broker.hivemq.com/mqtt", 8000)
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
@@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(openssl_tls_client_check) {
asio::ssl::context tls_context(asio::ssl::context::tls_client);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.brokers("broker.hivemq.com", 8883)
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })
@@ -217,7 +217,7 @@ BOOST_AUTO_TEST_CASE(websocket_tls_client_check) {
asio::ssl::context tls_context(asio::ssl::context::tls_client);
using client_type = mqtt_client<stream_type, decltype(tls_context)>;
client_type c(ioc, "", std::move(tls_context));
client_type c(ioc, std::move(tls_context));
c.brokers("broker.hivemq.com/mqtt", 8884)
.will({ "test/mqtt-test", "Client disconnected!", qos_e::at_least_once })

View File

@@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(async_run) {
auto strand = asio::make_strand(ioc);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1")
.async_run(asio::bind_executor(
strand,

View File

@@ -56,7 +56,7 @@ void run_test(
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.keep_alive(keep_alive)
.async_run(asio::detached);

View File

@@ -65,7 +65,7 @@ void run_test(
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1");
if constexpr (!std::is_same_v<Authenticator, std::monostate>)

View File

@@ -53,7 +53,7 @@ void test_receive_malformed_packet(
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);
@@ -146,7 +146,7 @@ BOOST_FIXTURE_TEST_CASE(receive_disconnect, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);
@@ -173,7 +173,7 @@ void run_receive_test(
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);

View File

@@ -63,7 +63,7 @@ void run_test(
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.connect_properties(cprops)
.async_run(asio::detached);
@@ -376,7 +376,7 @@ BOOST_FIXTURE_TEST_CASE(receive_buffer_overflow, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1")
.async_run(asio::detached);

View File

@@ -62,7 +62,7 @@ void run_test(
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);
@@ -506,7 +506,7 @@ BOOST_FIXTURE_TEST_CASE(cancel_resending_publish, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);
@@ -585,7 +585,7 @@ BOOST_FIXTURE_TEST_CASE(send_big_publish, shared_test_data) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);

View File

@@ -68,7 +68,7 @@ void run_test(test::msg_exchange broker_side) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);
@@ -395,7 +395,7 @@ void run_cancellation_test(test::msg_exchange broker_side) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1,127.0.0.1") // to avoid reconnect backoff
.async_run(asio::detached);

View File

@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(async_traits) {
BOOST_AUTO_TEST_CASE(client_functions) {
asio::io_context ioc;
mqtt_client<tcp_layer> tcp_client(ioc, "");
mqtt_client<tcp_layer> tcp_client(ioc);
tcp_client.authenticator(good_authenticator());
connack_props ca_props;
@@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(client_functions) {
asio::ssl::context ctx(asio::ssl::context::tls_client);
mqtt_client<
tls_layer, asio::ssl::context
> tls_client(ioc.get_executor(), "", std::move(ctx));
> tls_client(ioc.get_executor(), std::move(ctx));
tls_client.tls_context();
}

View File

@@ -25,7 +25,6 @@ void run_malformed_props_test(const disconnect_props& dprops) {
using client_service_type = test::test_service<asio::ip::tcp::socket>;
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
auto handler = [&handlers_called](error_code ec) {
++handlers_called;
BOOST_TEST(ec == client::error::malformed_packet);
@@ -102,7 +101,7 @@ BOOST_AUTO_TEST_CASE(omit_props) {
);
using client_type = mqtt_client<test::test_stream>;
client_type c(executor, "");
client_type c(executor);
c.brokers("127.0.0.1")
.async_run(asio::detached);

View File

@@ -20,7 +20,7 @@ BOOST_AUTO_TEST_CASE(pid_overrun) {
asio::io_context ioc;
using client_service_type = test::overrun_client<asio::ip::tcp::socket>;
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor(), "");
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
auto handler = [&handlers_called](error_code ec, reason_code rc, puback_props) {
++handlers_called;

View File

@@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(pid_overrun) {
asio::io_context ioc;
using client_service_type = test::overrun_client<asio::ip::tcp::socket>;
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor(), "");
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
auto handler = [&handlers_called](error_code ec, std::vector<reason_code> rcs, suback_props) {
++handlers_called;

View File

@@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(pid_overrun) {
asio::io_context ioc;
using client_service_type = test::overrun_client<asio::ip::tcp::socket>;
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor(), "");
auto svc_ptr = std::make_shared<client_service_type>(ioc.get_executor());
auto handler = [&handlers_called](error_code ec, std::vector<reason_code> rcs, unsuback_props) {
++handlers_called;