RMQ - RabbitMQ C++ Library
rmqa_rabbitcontextimpl.h
1// Copyright 2020-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16// rmqa_rabbitcontextimpl.h
17#ifndef INCLUDED_RMQA_RABBITCONTEXTIMPL
18#define INCLUDED_RMQA_RABBITCONTEXTIMPL
19
20#include <rmqa_connectionmonitor.h>
21#include <rmqa_rabbitcontextoptions.h>
22
23#include <rmqamqp_connection.h>
24#include <rmqio_eventloop.h>
25#include <rmqio_watchdog.h>
26#include <rmqp_connection.h>
27#include <rmqp_rabbitcontext.h>
28#include <rmqt_endpoint.h>
29#include <rmqt_future.h>
30#include <rmqt_result.h>
31#include <rmqt_vhostinfo.h>
32
33#include <bdlf_bind.h>
34#include <bdlmt_threadpool.h>
35#include <bsls_keyword.h>
36#include <bsls_timeinterval.h>
37
38#include <bsl_memory.h>
39#include <bsl_string.h>
40
41namespace BloombergLP {
42namespace rmqa {
43
45 public:
46 RabbitContextImpl(bslma::ManagedPtr<rmqio::EventLoop> eventLoop,
47 const rmqa::RabbitContextOptions& options);
48
50
51 bsl::shared_ptr<rmqp::Connection>
52 createVHostConnection(const bsl::string& userDefinedName,
53 const bsl::shared_ptr<rmqt::Endpoint>& endpoint,
54 const bsl::shared_ptr<rmqt::Credentials>& credentials)
55 BSLS_KEYWORD_OVERRIDE;
56
57 bsl::shared_ptr<rmqp::Connection> createVHostConnection(
58 const bsl::string& userDefinedName,
59 const rmqt::VHostInfo& endpoint) BSLS_KEYWORD_OVERRIDE;
60
62 createNewConnection(const bsl::string& name,
63 const bsl::shared_ptr<rmqt::Endpoint>& endpoint,
64 const bsl::shared_ptr<rmqt::Credentials>& credentials,
65 const bsl::string& suffix);
66
67 private:
68 RabbitContextImpl(const RabbitContextImpl&) BSLS_KEYWORD_DELETED;
69 RabbitContextImpl& operator=(const RabbitContextImpl&) BSLS_KEYWORD_DELETED;
70
71 private:
72 static const int DEFAULT_WATCHDOG_PERIOD = 60;
73 bslma::ManagedPtr<rmqio::EventLoop> d_eventLoop;
74 bsl::shared_ptr<rmqio::WatchDog> d_watchDog;
75 bdlmt::ThreadPool* d_threadPool;
76 bslma::ManagedPtr<bdlmt::ThreadPool> d_hostedThreadPool;
77 rmqt::ErrorCallback d_onError;
78 bsl::shared_ptr<ConnectionMonitor> d_connectionMonitor;
79 bslma::ManagedPtr<rmqamqp::Connection::Factory> d_connectionFactory;
80 rmqt::Tunables d_tunables;
81 bsl::shared_ptr<rmqp::ConsumerTracing> d_consumerTracing;
82 bsl::shared_ptr<rmqp::ProducerTracing> d_producerTracing;
83};
84
85} // namespace rmqa
86} // namespace BloombergLP
87
88#endif
Definition: rmqa_rabbitcontextimpl.h:44
bsl::shared_ptr< rmqp::Connection > createVHostConnection(const bsl::string &userDefinedName, const bsl::shared_ptr< rmqt::Endpoint > &endpoint, const bsl::shared_ptr< rmqt::Credentials > &credentials) BSLS_KEYWORD_OVERRIDE
Connect to a RabbitMQ broker.
Definition: rmqa_rabbitcontextimpl.cpp:270
Class for passing arguments to RabbitContext.
Definition: rmqa_rabbitcontextoptions.h:42
Interface for spawning RabbitMQ connections.
Definition: rmqp_rabbitcontext.h:40
An async-style Future/Promise object.
Definition: rmqt_future.h:108
Holds the VHost endpoint and credentials, used to connect.
Definition: rmqt_vhostinfo.h:28