Skip to content

Commit a3cda8c

Browse files
authored
Merge branch 'main' into onsuccess-callback
2 parents 35426b3 + 4bee462 commit a3cda8c

15 files changed

+94
-93
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
#Only run for push to main
2929
if: github.ref == 'refs/heads/main'
3030
runs-on: ubuntu-latest
31+
permissions:
32+
contents: write # Needed to push to gh-pages
3133
steps:
3234
- uses: actions/checkout@v3
3335
- name: Doxygenize

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ clean:
3232
rm -rf $(BUILD_FOLDER)
3333

3434
docker-setup:
35-
cd $(SRC_FOLDER)/dockerfiles && docker-compose build --pull
35+
cd $(SRC_FOLDER)/dockerfiles && docker compose build --pull
3636

3737
docker-build:
38-
cd $(SRC_FOLDER)/dockerfiles && docker-compose run dev make full
38+
cd $(SRC_FOLDER)/dockerfiles && docker compose run dev make full
3939

4040
docker-test:
41-
cd $(SRC_FOLDER)/dockerfiles && docker-compose run dev make full-test
41+
cd $(SRC_FOLDER)/dockerfiles && docker compose run dev make full-test
4242

4343
docker-shell:
44-
cd $(SRC_FOLDER)/dockerfiles && docker-compose run dev
44+
cd $(SRC_FOLDER)/dockerfiles && docker compose run dev
4545

4646
.PHONY: build init unit integration clean full full-test

docs/doxygen.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Metric publisher is used to publish internal library metrics. Users can provide
1818

1919
Error callback is called when a connection or channel is closed by the RabbitMQ broker.
2020

21-
Important -- `RabbitContext` object must outlive other library objects (`VHost`, `Producer`, `Consumer`).
21+
**Important** -- `RabbitContext` object **must outlive** other library objects (`VHost`, `Producer`, `Consumer`).
2222

2323
```cpp
2424

@@ -51,6 +51,7 @@ bsl::shared_ptr<rmqa::VHost> vhost = context.createVHostConnection(
5151

5252
Creating a `rmqa::VHost` instance **does not** immediately create a connection with the RabbitMQ broker. These connections are created lazily when calling `rmqa::VHost::createProducer` and `rmqa::VHost::createConsumer`.
5353

54+
**Important** -- `VHost` object **must outlive** other library objects (`Producer`, `Consumer`).
5455

5556
## Topology
5657

src/rmq/rmqamqp/rmqamqp_connection.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,10 @@ class Connection::ConnectionMethodProcessor {
630630
conn.sendConnectionCloseOk();
631631

632632
if (closeMethod.classId() || closeMethod.methodId()) {
633-
conn.d_retryHandler->errorCallback()("Connection error " +
634-
closeMethod.replyText(),
635-
closeMethod.replyCode());
633+
conn.d_retryHandler->errorCallback()(
634+
"Connection=" + conn.d_connectionName + " Connection error " +
635+
closeMethod.replyText(),
636+
closeMethod.replyCode());
636637
}
637638
}
638639

src/rmq/rmqio/rmqio_asioconnection.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ AsioConnection<SocketType>::prepareBuffer()
433433
template <typename SocketType>
434434
bool AsioConnection<SocketType>::doRead(bsl::size_t bytes_transferred)
435435
{
436-
437436
bool success = true;
438437

439438
// d_inbound is setup with a buffer size of maxFrameSize in ::prepareBuffer
@@ -444,20 +443,21 @@ bool AsioConnection<SocketType>::doRead(bsl::size_t bytes_transferred)
444443
bsl::size_t bytes_decoded = 0;
445444
boost::asio::streambuf::const_buffers_type bufs = d_inbound->data();
446445
bsl::vector<rmqamqpt::Frame> readFrames;
447-
for (boost::asio::streambuf::const_buffers_type::const_iterator i =
448-
bufs.begin();
449-
i != bufs.end();
450-
++i) {
451-
boost::asio::const_buffer buf(*i);
452-
Decoder::ReturnCode rcode =
453-
d_frameDecoder->appendBytes(&readFrames, buf.data(), buf.size());
446+
447+
for (const boost::asio::const_buffer* it =
448+
boost::asio::buffer_sequence_begin(bufs);
449+
it != boost::asio::buffer_sequence_end(bufs);
450+
++it) {
451+
const boost::asio::const_buffer& buffer = *it;
452+
Decoder::ReturnCode rcode = d_frameDecoder->appendBytes(
453+
&readFrames, buffer.data(), buffer.size());
454454
if (rcode != Decoder::OK) {
455455
BALL_LOG_WARN << "Bad rcode from decoder: " << rcode;
456456
// Fail but we still want to process frames we were able to decode
457457
success = false;
458-
break;
459-
};
460-
bytes_decoded += buf.size();
458+
break; // Exit the loop on error
459+
}
460+
bytes_decoded += buffer.size();
461461
}
462462

463463
if (bytes_decoded != bytes_transferred) {

src/rmq/rmqio/rmqio_asioeventloop.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,15 @@ void AsioEventLoop::onThreadStarted()
108108
d_condition.broadcast();
109109
}
110110

111-
void AsioEventLoop::postImpl(const Item& item) { d_context.post(item); }
112-
void AsioEventLoop::dispatchImpl(const Item& item) { d_context.dispatch(item); }
111+
void AsioEventLoop::postImpl(const Item& item)
112+
{
113+
boost::asio::post(d_context, item);
114+
}
115+
116+
void AsioEventLoop::dispatchImpl(const Item& item)
117+
{
118+
boost::asio::dispatch(d_context, item);
119+
}
113120

114121
bsl::shared_ptr<rmqio::Resolver>
115122
AsioEventLoop::resolver(bool shuffleConnectionEndpoints)

src/tests/rmqa/rmqa_connectionstring.t.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include <rmqa_connectionstring.h>
1717

18+
#include <rmqtestutil_testsuite.t.h>
19+
1820
#include <bsl_string.h>
1921

2022
#include <gmock/gmock.h>
@@ -98,10 +100,6 @@ const ConnectionStringTestCase k_CONN_STRING_TESTS[] = {
98100
{"amqp://rabbit1.:", false, "", "", "", "", "", ""},
99101
};
100102

101-
// We need to stick to INSTANTIATE_TEST_CASE_P for a while longer
102-
// But we do want to build with -Werror in our CI
103-
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
104-
105-
INSTANTIATE_TEST_CASE_P(ConnectionStringTests,
103+
RMQTESTUTIL_TESTSUITE_P(ConnectionStringTests,
106104
ConnectionStringPTests,
107105
testing::ValuesIn(k_CONN_STRING_TESTS));

src/tests/rmqa/rmqa_consumerimpl.t.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <rmqtestutil_mockchannel.t.h>
2424
#include <rmqtestutil_mockeventloop.t.h>
2525
#include <rmqtestutil_savethreadid.h>
26+
#include <rmqtestutil_testsuite.t.h>
2627

2728
#include <rmqt_consumerackbatch.h>
2829
#include <rmqt_envelope.h>
@@ -449,11 +450,7 @@ TEST_P(ConsumerImplTests, UpdateCallbackFromTwoThreadsAtOnce)
449450
EXPECT_TRUE(future2.blockResult());
450451
}
451452

452-
// We need to stick to INSTANTIATE_TEST_CASE_P for a while longer
453-
// But we do want to build with -Werror in our CI
454-
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
455-
456-
INSTANTIATE_TEST_CASE_P(AllMembers,
453+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
457454
ConsumerImplTests,
458455
Values(CONSUMER, TRACING_CONSUMER),
459456
ConsumerImplTests::PrintParamName());

src/tests/rmqa/rmqa_producerimpl.t.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <rmqtestutil_mockchannel.t.h>
2323
#include <rmqtestutil_mockeventloop.t.h>
2424
#include <rmqtestutil_savethreadid.h>
25+
#include <rmqtestutil_testsuite.t.h>
2526

2627
#include <rmqp_producer.h>
2728
#include <rmqt_confirmresponse.h>
@@ -815,32 +816,28 @@ TEST_P(TracingProducerImplTests, SendConfirmCallsTracing)
815816
d_threadPool.drain();
816817
}
817818

818-
// We need to stick to INSTANTIATE_TEST_CASE_P for a while longer
819-
// But we do want to build with -Werror in our CI
820-
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
821-
822-
INSTANTIATE_TEST_CASE_P(AllMembers,
819+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
823820
ProducerImplTests,
824821
Values(PRODUCER, TRACING_PRODUCER),
825822
ProducerImplTests::PrintParamName());
826-
INSTANTIATE_TEST_CASE_P(AllMembers,
823+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
827824
ProducerImplConfirmTypeTests,
828825
Values(PRODUCER, TRACING_PRODUCER),
829826
ProducerImplTests::PrintParamName());
830-
INSTANTIATE_TEST_CASE_P(AllMembers,
827+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
831828
ProducerImplCallbackLifetimeTests,
832829
Values(PRODUCER, TRACING_PRODUCER),
833830
ProducerImplTests::PrintParamName());
834-
INSTANTIATE_TEST_CASE_P(AllMembers,
831+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
835832
ProducerImplMaxOutstandingTests,
836833
Values(PRODUCER, TRACING_PRODUCER),
837834
ProducerImplTests::PrintParamName());
838-
INSTANTIATE_TEST_CASE_P(AllMembers,
835+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
839836
ProducerImplUpdateTopology,
840837
Values(PRODUCER, TRACING_PRODUCER),
841838
ProducerImplTests::PrintParamName());
842839

843-
INSTANTIATE_TEST_CASE_P(AllMembers,
840+
RMQTESTUTIL_TESTSUITE_P(AllMembers,
844841
TracingProducerImplTests,
845842
Values(TRACING_PRODUCER),
846843
ProducerImplTests::PrintParamName());

src/tests/rmqamqp/rmqamqp_connection.t.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class MockConnection : public rmqio::Connection {
149149

150150
BSLS_ASSERT_OPT(rc == Frame::OK);
151151

152-
d_eventLoop.post(
152+
boost::asio::post(
153+
d_eventLoop,
153154
bdlf::BindUtil::bind(d_connectionCallbacks.onRead, decoded));
154155
}
155156
}
@@ -158,7 +159,8 @@ class MockConnection : public rmqio::Connection {
158159
{
159160
BALL_LOG_TRACE << "MockConnection close";
160161

161-
d_eventLoop.post(bdlf::BindUtil::bind(cb, GRACEFUL_DISCONNECT));
162+
boost::asio::post(d_eventLoop,
163+
bdlf::BindUtil::bind(cb, GRACEFUL_DISCONNECT));
162164
}
163165

164166
void asyncWriteImpl(
@@ -177,7 +179,7 @@ class MockConnection : public rmqio::Connection {
177179
rmqamqpt::Method(
178180
rmqamqpt::ConnectionMethod(rmqamqpt::ConnectionCloseOk())));
179181

180-
d_eventLoop.post(callback);
182+
boost::asio::post(d_eventLoop, callback);
181183

182184
if (!closeOk) {
183185
feedNextFrame();
@@ -303,7 +305,7 @@ ACTION_P3(ConnectMockConnection, mockConnectPtrPtr, replayFrame, eventLoop)
303305

304306
ON_CALL(**mockConnectPtrPtr, isConnected()).WillByDefault(Return(true));
305307

306-
eventLoop.get().post(arg4);
308+
boost::asio::post(eventLoop.get(), arg4);
307309

308310
return *mockConnectPtrPtr;
309311
}

0 commit comments

Comments
 (0)