Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor AMQP logic to better isolate rust AMQP code from uAMQP code. #6008

Merged

Conversation

LarryOsterman
Copy link
Member

@LarryOsterman LarryOsterman commented Sep 18, 2024

Most of this change is refactoring code, but there is a significant difference in this PR:

doxygen really doesn't handle conditional compilation well if there are ambiguous filenames in the repo. A large part of how this refactoring works depends on the fact that there are files with the same name in two different locations, so doxygen doesn't do well with this.

To resolve the issue, I changed doxygen to scope to just files in the "inc" subdirectory and the readme.md file.

That may result in public APIs which are not in the "inc" directory being dropped, but we shouldn't have any public APIs which aren't in the "inc" subdirectory.

@LarryOsterman
Copy link
Member Author

Ping :).

@LarryOsterman
Copy link
Member Author

Ping please.

@ahsonkhan
Copy link
Member

Hi Larry, this is a fairly large PR (I understand a lot of it is refactoring). How would you recommend we review it? Put another way, what areas should we try to focus our attention on, which you think will be the most valuable for you?

@LarryOsterman
Copy link
Member Author

Hi Larry, this is a fairly large PR (I understand a lot of it is refactoring). How would you recommend we review it? Put another way, what areas should we try to focus our attention on, which you think will be the most valuable for you?

You should ignore the moved files - that's about 250 or so of the files in the PR.

Concentrate on the 50 or so remaining files.

The vast majority of the changes are removing #if UAMQP conditionals from the UAMQP specific code, and removing UAMQP specific code from the rust implementation.

Note that there are some vestiges of the UAMQP stuff in the rust implementations, that's done so I have boilerplate in place to make the rust implementations of stuff that's not there yet.

LarryOsterman and others added 2 commits September 20, 2024 16:02
…r than attempting to run; removed some uAMQP-only features (Azure#5986)

* Checkpoint of connection logic

* Started implementing Rust based Connection by pulling out uAMQP artifacts

* Implemented AMQP Connection in Rust; started API surface refactoring for Rust APIs; Refactored tests to remove some uAMQP only elements.

* Don't leak runtime context on calls

* export UUID from AMQP

* clang-format
@LarryOsterman LarryOsterman merged commit ec564d5 into Azure:feature/rust_amqp Sep 20, 2024
3 of 6 checks passed
@LarryOsterman LarryOsterman deleted the larryo/refactor_amqp branch September 20, 2024 23:03
Copy link
Member

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the 112/383 files as best I could at a high level.
I believe the rest are all file renames without changes.

@@ -58,6 +58,7 @@ function(generate_documentation PROJECT_NAME PROJECT_VERSION)
set(DOXYGEN_REPEAT_BRIEF NO)

doxygen_add_docs(${PROJECT_NAME}-docs
./inc ./README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this have any impact on the "root readmes" being published for each package? For example, if we exclude https://github.com/Azure/azure-sdk-for-cpp/blob/main/sdk/storage/azure-storage-blobs/README.md does that mean, the published docs won't have:
https://azuresdkdocs.blob.core.windows.net/$web/cpp/azure-storage-blobs/12.12.0/index.html

Comment on lines +175 to +182
src/impl/uamqp/amqp/private/session_impl.hpp
# src/impl/uamqp/models/amqp_detach.cpp
# src/impl/uamqp/models/amqp_error.cpp
# src/impl/uamqp/models/amqp_header.cpp
# src/impl/uamqp/models/amqp_message.cpp
# src/impl/uamqp/models/amqp_properties.cpp
# src/impl/uamqp/models/amqp_transfer.cpp
# src/impl/uamqp/models/amqp_value.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are some of these commented out?

Comment on lines +247 to +250
if (USE_UAMQP)
add_library(azure-core-amqp ${AZURE_CORE_AMQP_SOURCE} ${AZURE_CORE_AMQP_HEADER} ${AZURE_UAMQP_SOURCE} $<TARGET_OBJECTS:uamqp>)
elseif(USE_RUST_AMQP)
add_library(azure-core-amqp ${AZURE_CORE_AMQP_SOURCE} ${AZURE_CORE_AMQP_HEADER})
add_library(azure-core-amqp ${AZURE_CORE_AMQP_SOURCE} ${AZURE_CORE_AMQP_HEADER} ${AZURE_RUST_AMQP_SOURCE})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are USE_UAMQP and USE_RUST_AMQP mutually exclusive? If so, should the above set(AZURE_RUST_AMQP_SOURCE ... also be in an if/elseif rather than two independent if blocks? It might be easier to read and be consistent if we combine all the if/elseif into one block.

endif()

if (USE_UAMQP)
target_include_directories(azure-core-amqp SYSTEM PRIVATE ${UAMQP_INC_FOLDER})
target_include_directories(azure-core-amqp PRIVATE src/impl/uamqp/amqp/private src/impl/uamqp/amqp/network ${UAMQP_INC_FOLDER})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we including UAMQP_INC_FOLDER twice (in both target_include_directories calls)?

class RustThreadContext final {

/**
* @brief Represents the an implementation of the rust multithreaded runtime.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Represents the an implementation of the rust multithreaded runtime.
* @brief Represents an implementation of the rust multithreaded runtime.

@@ -3,9 +3,7 @@

#include "azure/core/amqp/internal/cancellable.hpp"

#if ENABLE_UAMQP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to remove this now because the entire file is conditionally compiled now?


using namespace Azure::Core::Diagnostics::_internal;
using namespace Azure::Core::Diagnostics;
using namespace Azure::Core::Amqp::_internal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spot checking the difference, and it looks like this file is identical to the one:
sdk/core/azure-core-amqp/src/impl/rust_amqp/amqp/claim_based_security.cpp

Except for this line 14 is above namespace Azure { namespace Core { namespace Amqp { namespace _detail { here, and below in the rust amqp impl version.

Should they be identical?
Can you explain why we need two copies for what you are trying to achieve?

Comment on lines +48 to +51
#if ENABLE_UAMQP
GTEST_LOG_(INFO) << LinkState::Error << LinkState::Invalid << static_cast<LinkState>(92)
<< LinkState::HalfAttachedAttachReceived;
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to follow/understand why we end up needing the #ifs in some of these tests, in these particular places. Can you provide some context on how you went about introducing these?

Comment on lines +92 to +97
if (result)
{
throw Azure::Messaging::EventHubs::_detail::EventHubsExceptionFactory::
CreateEventHubsException(result);
}
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the inverse? That is:
if(result) return true;

Comment on lines +45 to +46
endif()
if (USE_RUST_AMQP)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elif?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants