RMQ - RabbitMQ C++ Library
rmqa_rabbitcontextoptions.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_rabbitcontextoptions.h
17#ifndef INCLUDED_RMQA_RABBITCONTEXTOPTIONS
18#define INCLUDED_RMQA_RABBITCONTEXTOPTIONS
19
20#include <rmqp_metricpublisher.h>
21
22#include <rmqp_consumertracing.h>
23#include <rmqp_producertracing.h>
24#include <rmqt_fieldvalue.h>
25#include <rmqt_properties.h>
26#include <rmqt_result.h>
27
28#include <bdlmt_threadpool.h>
29#include <bsl_memory.h>
30#include <bsl_set.h>
31#include <bsls_timeinterval.h>
32
33namespace BloombergLP {
34namespace rmqa {
35
41
43 public:
44 typedef bsl::set<bsl::string> Tunables;
45
58
69 RabbitContextOptions& setThreadpool(bdlmt::ThreadPool* threadpool);
70
74 const bsl::shared_ptr<rmqp::MetricPublisher>& metricPublisher);
75
79 setErrorCallback(const rmqt::ErrorCallback& errorCallback);
80
93 RabbitContextOptions& setClientProperty(const bsl::string& name,
94 const rmqt::FieldValue& value);
95
106 setMessageProcessingTimeout(const bsls::TimeInterval& timeout);
107
113 const bsl::optional<bsls::TimeInterval>& timeout);
114
121 const bsl::shared_ptr<rmqp::ConsumerTracing>& consumerTracing);
122
129 const bsl::shared_ptr<rmqp::ProducerTracing>& producerTracing);
130
134
142 setShuffleConnectionEndpoints(bool shuffleConnectionEndpoints);
143
144 bdlmt::ThreadPool* threadpool() const { return d_threadpool; }
145
146 const bsl::shared_ptr<rmqp::MetricPublisher>& metricPublisher() const
147 {
148 return d_metricPublisher;
149 }
150
151 const rmqt::ErrorCallback& errorCallback() const { return d_onError; }
152
153 const rmqt::FieldTable& clientProperties() const
154 {
155 return d_clientProperties;
156 }
157
158 const bsls::TimeInterval& messageProcessingTimeout() const
159 {
160 return d_messageProcessingTimeout;
161 }
162
163 const bsl::optional<bsls::TimeInterval>& connectionErrorThreshold() const
164 {
165 return d_connectionErrorThreshold;
166 }
167
168 const rmqt::Tunables& tunables() const { return d_tunables; }
169
170 const bsl::shared_ptr<rmqp::ConsumerTracing>& consumerTracing() const
171 {
172 return d_consumerTracing;
173 }
174
175 const bsl::shared_ptr<rmqp::ProducerTracing>& producerTracing() const
176 {
177 return d_producerTracing;
178 }
179
180 const bsl::optional<bool>& shuffleConnectionEndpoints() const
181 {
182 return d_shuffleConnectionEndpoints;
183 }
184
185#ifdef USES_LIBRMQ_EXPERIMENTAL_FEATURES
186 RabbitContextOptions& setTunable(const bsl::string& tunable);
187#endif
188
189 private:
190 static const int DEFAULT_MESSAGE_PROCESSING_TIMEOUT = 60;
191 bdlmt::ThreadPool* d_threadpool;
192 rmqt::ErrorCallback d_onError;
193 bsl::shared_ptr<rmqp::MetricPublisher> d_metricPublisher;
194 rmqt::FieldTable d_clientProperties;
195 bsls::TimeInterval d_messageProcessingTimeout;
196 rmqt::Tunables d_tunables;
197 bsl::optional<bsls::TimeInterval> d_connectionErrorThreshold;
198 bsl::shared_ptr<rmqp::ConsumerTracing> d_consumerTracing;
199 bsl::shared_ptr<rmqp::ProducerTracing> d_producerTracing;
200 bsl::optional<bool> d_shuffleConnectionEndpoints;
201};
202
203} // namespace rmqa
204} // namespace BloombergLP
205
206#endif
Class for passing arguments to RabbitContext.
Definition: rmqa_rabbitcontextoptions.h:42
RabbitContextOptions & setProducerTracing(const bsl::shared_ptr< rmqp::ProducerTracing > &producerTracing)
will be called back at message send, with meta data to establish a context, the context will be kept ...
Definition: rmqa_rabbitcontextoptions.cpp:124
RabbitContextOptions()
By Default RabbitContext will 1) Create it's own threadpool for calling back to client code e....
Definition: rmqa_rabbitcontextoptions.cpp:59
RabbitContextOptions & useRabbitMQFieldValueEncoding(bool rabbitEncoding)
DEPRECATED: Previously was used to switch between AMQP-spec and RabbitMQ-spec Field Value encoding....
Definition: rmqa_rabbitcontextoptions.cpp:131
RabbitContextOptions & setThreadpool(bdlmt::ThreadPool *threadpool)
Definition: rmqa_rabbitcontextoptions.cpp:75
RabbitContextOptions & setConnectionErrorThreshold(const bsl::optional< bsls::TimeInterval > &timeout)
Set time threshold at which point the error callback is called if there has been no success in establ...
Definition: rmqa_rabbitcontextoptions.cpp:110
RabbitContextOptions & setErrorCallback(const rmqt::ErrorCallback &errorCallback)
Definition: rmqa_rabbitcontextoptions.cpp:82
RabbitContextOptions & setShuffleConnectionEndpoints(bool shuffleConnectionEndpoints)
Shuffle endpoints rmq connects to. By default, boost asio (libc) resolves and connects to the node wi...
Definition: rmqa_rabbitcontextoptions.cpp:136
RabbitContextOptions & setMessageProcessingTimeout(const bsls::TimeInterval &timeout)
Set time in which consumers should process messages.
Definition: rmqa_rabbitcontextoptions.cpp:103
RabbitContextOptions & setMetricPublisher(const bsl::shared_ptr< rmqp::MetricPublisher > &metricPublisher)
Definition: rmqa_rabbitcontextoptions.cpp:88
RabbitContextOptions & setConsumerTracing(const bsl::shared_ptr< rmqp::ConsumerTracing > &consumerTracing)
will be called back to create a context which spans for the lifetime of the messageguard before it is...
Definition: rmqa_rabbitcontextoptions.cpp:117
RabbitContextOptions & setClientProperty(const bsl::string &name, const rmqt::FieldValue &value)
Definition: rmqa_rabbitcontextoptions.cpp:96
Represents AMQP 0.9.1 Field Table (dict of FieldValues)
Definition: rmqt_fieldvalue.h:108