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
87 RabbitContextOptions& setClientProperty(const bsl::string& name,
88 const rmqt::FieldValue& value);
89
100 setMessageProcessingTimeout(const bsls::TimeInterval& timeout);
101
107 const bsl::optional<bsls::TimeInterval>& timeout);
108
115 const bsl::shared_ptr<rmqp::ConsumerTracing>& consumerTracing);
116
123 const bsl::shared_ptr<rmqp::ProducerTracing>& producerTracing);
124
128
136 setShuffleConnectionEndpoints(bool shuffleConnectionEndpoints);
137
138 bdlmt::ThreadPool* threadpool() const { return d_threadpool; }
139
140 const bsl::shared_ptr<rmqp::MetricPublisher>& metricPublisher() const
141 {
142 return d_metricPublisher;
143 }
144
145 const rmqt::ErrorCallback& errorCallback() const { return d_onError; }
146
147 const rmqt::FieldTable& clientProperties() const
148 {
149 return d_clientProperties;
150 }
151
152 const bsls::TimeInterval& messageProcessingTimeout() const
153 {
154 return d_messageProcessingTimeout;
155 }
156
157 const bsl::optional<bsls::TimeInterval>& connectionErrorThreshold() const
158 {
159 return d_connectionErrorThreshold;
160 }
161
162 const rmqt::Tunables& tunables() const { return d_tunables; }
163
164 const bsl::shared_ptr<rmqp::ConsumerTracing>& consumerTracing() const
165 {
166 return d_consumerTracing;
167 }
168
169 const bsl::shared_ptr<rmqp::ProducerTracing>& producerTracing() const
170 {
171 return d_producerTracing;
172 }
173
174 const bsl::optional<bool>& shuffleConnectionEndpoints() const
175 {
176 return d_shuffleConnectionEndpoints;
177 }
178
179#ifdef USES_LIBRMQ_EXPERIMENTAL_FEATURES
180 RabbitContextOptions& setTunable(const bsl::string& tunable);
181#endif
182
183 private:
184 static const int DEFAULT_MESSAGE_PROCESSING_TIMEOUT = 60;
185 bdlmt::ThreadPool* d_threadpool;
186 rmqt::ErrorCallback d_onError;
187 bsl::shared_ptr<rmqp::MetricPublisher> d_metricPublisher;
188 rmqt::FieldTable d_clientProperties;
189 bsls::TimeInterval d_messageProcessingTimeout;
190 rmqt::Tunables d_tunables;
191 bsl::optional<bsls::TimeInterval> d_connectionErrorThreshold;
192 bsl::shared_ptr<rmqp::ConsumerTracing> d_consumerTracing;
193 bsl::shared_ptr<rmqp::ProducerTracing> d_producerTracing;
194 bsl::optional<bool> d_shuffleConnectionEndpoints;
195};
196
197} // namespace rmqa
198} // namespace BloombergLP
199
200#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