Skip to content

Commit

Permalink
Initial creation of EventHubs service by @gearama (#4755)
Browse files Browse the repository at this point in the history
  • Loading branch information
LarryOsterman authored Jul 13, 2023
1 parent 5ea8947 commit a627ab3
Show file tree
Hide file tree
Showing 59 changed files with 4,688 additions and 89 deletions.
44 changes: 25 additions & 19 deletions cmake-modules/FolderList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@ macro(GetFolderList project)
message ("project found ${project}")
message ("FLAG VALUE : ${FETCH_SOURCE_DEPS}")
if(${project} STREQUAL CERTIFICATES)
DownloadDepVersion(sdk/core azure-core 1.5.0)
DownloadDepVersion(sdk/identity azure-identity 1.1.0)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/identity azure-identity)
elseif(${project} STREQUAL IDENTITY)
DownloadDepVersion(sdk/core azure-core 1.2.0)
DownloadDepVersion(sdk/core azure-core)
elseif(${project} STREQUAL SECRETS)
DownloadDepVersion(sdk/core azure-core 1.5.0)
DownloadDepVersion(sdk/identity azure-identity 1.1.0)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/identity azure-identity)
elseif(${project} STREQUAL KEYS)
DownloadDepVersion(sdk/core azure-core 1.5.0)
DownloadDepVersion(sdk/identity azure-identity 1.1.0)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/identity azure-identity)
elseif(${project} STREQUAL ADMINISTRATION)
DownloadDepVersion(sdk/core azure-core 1.5.0)
DownloadDepVersion(sdk/identity azure-identity 1.1.0)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/identity azure-identity)
elseif(${project} STREQUAL STORAGE_COMMON)
DownloadDepVersion(sdk/core azure-core 1.9.0)
DownloadDepVersion(sdk/core azure-core)
elseif(${project} STREQUAL STORAGE_BLOBS)
DownloadDepVersion(sdk/core azure-core 1.8.0)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common 12.3.1)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common)
elseif(${project} STREQUAL STORAGE_FILES_DATALAKE)
DownloadDepVersion(sdk/core azure-core 1.8.0)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common 12.3.1)
DownloadDepVersion(sdk/storage/azure-storage-blobs azure-storage-blobs 12.7.0)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common)
DownloadDepVersion(sdk/storage/azure-storage-blobs azure-storage-blobs)
elseif(${project} STREQUAL STORAGE_FILES_SHARES)
DownloadDepVersion(sdk/core azure-core 1.9.0)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common 12.3.2)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common)
elseif(${project} STREQUAL STORAGE_QUEUES)
DownloadDepVersion(sdk/core azure-core 1.5.0)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common 12.2.3)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common)
elseif(${project} STREQUAL EVENTHUBS)
DownloadDepVersion(sdk/core azure-core)
DownloadDepVersion(sdk/core azure-core-amqp)
DownloadDepVersion(sdk/storage/azure-storage-common azure-storage-common)
DownloadDepVersion(sdk/storage/azure-storage-blobs azure-storage-blobs)
elseif(${project} STREQUAL STORAGE_FILES_DATALAKE)
endif()
list(REMOVE_DUPLICATES BUILD_FOLDERS)
endmacro()
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
vstsFeed: 'internal/AzureSDKForCpp'
vstsFeedPackage: 'parseazuresdkcpp'
downloadDirectory: '$(System.DefaultWorkingDirectory)/parser'
vstsPackageVersion: 0.7.0
vstsPackageVersion: 0.8.0
condition: >-
and(
succeeded(),
Expand Down
9 changes: 8 additions & 1 deletion eng/pipelines/templates/steps/cmake-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ steps:

# Non-core services define the list of targets to build
- ${{ if and(eq(parameters.Build, true) , ne(parameters.ServiceDirectory, 'core')) }}:
- pwsh: cmake --build . ${{ parameters.BuildArgs }} --target (Get-Content ${{ parameters.ServiceDirectory }}-targets-build.txt)
- pwsh: |
if (Test-Path ${{ parameters.ServiceDirectory }}-targets-build.txt) {
cmake --build . ${{ parameters.BuildArgs }} --target (Get-Content ${{ parameters.ServiceDirectory }}-targets-build.txt)
}
else
{
echo "Skipping Build Target for service ${{parameters.ServiceDirectory}}"
}
workingDirectory: build
displayName: cmake build Targets
14 changes: 9 additions & 5 deletions eng/scripts/Get-BinarySizes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,16 @@ function getBuildConfiguration {
return "Debug"
}

$searchPath = "$BuildDirectory/sdk/$ServiceDirectory/*/*.a"
if ($IsWindows) {
$searchPath = "$BuildDirectory/sdk/$ServiceDirectory/*/*/*.lib"
}
# It's possible that due to external factors, the build directory doesn't exist.
if (Test-Path "$BuildDirectory/sdk/$ServiceDirectory") {

$searchPath = "$BuildDirectory/sdk/$ServiceDirectory/*/*.a"
if ($IsWindows) {
$searchPath = "$BuildDirectory/sdk/$ServiceDirectory/*/*/*.lib"
}

$binaries = Get-ChildItem -Path $searchPath
$binaries = Get-ChildItem -Path $searchPath
}

$buildLabels = @{
TargetOs = getTargetOs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
};
using UniqueMessageHandle = Azure::Core::_internal::UniqueHandle<MESSAGE_INSTANCE_TAG>;

constexpr int AmqpMessageFormatValue = 0; // Specifies the message format for an AMQP message.
constexpr int AmqpDefaultMessageFormatValue
= 0; // Specifies the message format for an AMQP message.

/** @brief An AmqpMessage object represents a received AMQP message.
* @remark An AMQP message is comprised of a header, properties, application properties, and
Expand Down Expand Up @@ -96,6 +97,13 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
*/
operator bool() const noexcept { return m_hasValue; }

/** @brief The message format.
*
* By default, AMQP uses 0, however services can override this to
* express additional semantics about the message payload.
*/
uint32_t MessageFormat = AmqpDefaultMessageFormatValue;

/** @brief The header for the message.
*
* For more information, see [AMQP Message
Expand Down Expand Up @@ -246,19 +254,19 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
*
* @remarks This API will fail if BodyType is not MessageBodyType::Sequence.
*/
std::vector<AmqpList> GetBodyAsAmqpList() const;
std::vector<AmqpList> const& GetBodyAsAmqpList() const;

/** @brief Returns an Amqp Value message body.
*
* @remarks This API will fail if BodyType is not MessageBodyType::Value.
*/
AmqpValue GetBodyAsAmqpValue() const;
AmqpValue const& GetBodyAsAmqpValue() const;

/** @brief Returns an Amqp Binary message body.
*
* @remarks This API will fail if BodyType is not MessageBodyType::Binary.
*/
std::vector<AmqpBinaryData> GetBodyAsBinary() const;
std::vector<AmqpBinaryData> const& GetBodyAsBinary() const;

/** @brief Serialize the message into a buffer.
*
Expand Down Expand Up @@ -292,6 +300,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace
* layer.
*/
class AmqpMessageFactory final {
AmqpMessageFactory() = delete;

public:
static AmqpMessage FromUamqp(UniqueMessageHandle const& properties);
static AmqpMessage FromUamqp(MESSAGE_INSTANCE_TAG* properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace
* layer.
*/
class MessagePropertiesFactory final {
MessagePropertiesFactory() = delete;

public:
static MessageProperties FromUamqp(UniquePropertiesHandle const& properties);
static UniquePropertiesHandle ToUamqp(MessageProperties const& properties);
Expand Down
12 changes: 12 additions & 0 deletions sdk/core/azure-core-amqp/inc/azure/core/amqp/models/amqp_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace
AmqpCollectionBase() {}

public:
/** @brief Returns the underlying value.
*/
explicit operator T const &() const { return m_value; }

/** @brief Convert this collection type to an AMQP value.*/
explicit operator AmqpValue() const { return static_cast<UniqueAmqpValueHandle>(*this).get(); }

Expand All @@ -602,6 +606,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models { namespace
void push_back(typename T::value_type&& val) { m_value.push_back(val); }
typename T::const_iterator begin() const noexcept { return m_value.begin(); }
typename T::const_iterator end() const noexcept { return m_value.end(); }
size_t find(T const& val) noexcept { return m_value.find(val); }
typename T::value_type* data() noexcept { return m_value.data(); }
const typename T::value_type* data() const noexcept { return m_value.data(); }
const typename T::value_type& at(const typename T::size_type pos) const
Expand Down Expand Up @@ -744,6 +749,13 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
/** @brief Construct a new AmqpBinaryData from a vector of bytes. */
AmqpBinaryData(std::vector<std::uint8_t> const& values) : AmqpCollectionBase(values){};

/** @brief Assign a vector of bytes to the current AmqpBinaryData. */
AmqpBinaryData& operator=(std::vector<std::uint8_t> const& values)
{
m_value = values;
return *this;
};

/** @brief Construct a new AmqpBinaryData object from an existing uAMQP AMQP_VALUE item
*
* @remarks Note that this does NOT capture the passed in AMQP_VALUE object, the caller is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
uint64_t m_nextMessageId{0};

// What is the message ID expected for the current outstanding operation?
uint64_t m_expectedMessageId;
uint64_t m_expectedMessageId{};
bool m_sendCompleted{false};

void SetState(ManagementState newState);
Expand Down
14 changes: 9 additions & 5 deletions sdk/core/azure-core-amqp/src/models/amqp_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
{
UniqueMessageHandle rv(message_create());

// AMQP 1.0 specifies a message format of 0.
if (message_set_message_format(rv.get(), AmqpMessageFormatValue))
// AMQP 1.0 specifies a message format of 0, but EventHubs uses other values.
if (message_set_message_format(rv.get(), message.MessageFormat))
{
throw std::runtime_error("Could not set destination message format.");
}
Expand Down Expand Up @@ -330,7 +330,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
return rv;
}

std::vector<AmqpList> AmqpMessage::GetBodyAsAmqpList() const
std::vector<AmqpList> const& AmqpMessage::GetBodyAsAmqpList() const
{
if (BodyType != MessageBodyType::Sequence)
{
Expand Down Expand Up @@ -365,15 +365,15 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
m_amqpSequenceBody.push_back(value);
}

AmqpValue AmqpMessage::GetBodyAsAmqpValue() const
AmqpValue const& AmqpMessage::GetBodyAsAmqpValue() const
{
if (BodyType != MessageBodyType::Value)
{
throw std::runtime_error("Invalid body type, should be MessageBodyType::Value.");
}
return m_amqpValueBody;
}
std::vector<AmqpBinaryData> AmqpMessage::GetBodyAsBinary() const
std::vector<AmqpBinaryData> const& AmqpMessage::GetBodyAsBinary() const
{
if (BodyType != MessageBodyType::Data)
{
Expand Down Expand Up @@ -716,6 +716,10 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
std::ostream& operator<<(std::ostream& os, AmqpMessage const& message)
{
os << "Message: " << std::endl;
if (message.MessageFormat != AmqpDefaultMessageFormatValue)
{
os << " Message Format: " << message.MessageFormat << std::endl;
}
os << " Header " << message.Header << std::endl;
os << " Properties: " << message.Properties << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core-amqp/src/models/amqp_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Models {
std::ostream& operator<<(std::ostream& os, AmqpSymbol const& value)
{
// Let the AmqpValue specialization handle serialization of the array.
AmqpValue arrayValue(value);
AmqpValue arrayValue(static_cast<AmqpValue>(value));
os << arrayValue;
return os;
}
Expand Down
1 change: 1 addition & 0 deletions sdk/core/azure-core-test/inc/azure/core/test/test_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/**
* Base class for running live and playback tests using the interceptor manager
*/
#pragma once

#include "azure/core/test/network_models.hpp"
#include "azure/core/test/test_context_manager.hpp"
Expand Down
6 changes: 6 additions & 0 deletions sdk/eventhubs/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/eventhubs",
"Tag": ""
}
13 changes: 13 additions & 0 deletions sdk/eventhubs/azure-messaging-eventhubs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

### Features Added

Initial Release.

### Breaking Changes

### Bugs Fixed

### Other Changes
Loading

0 comments on commit a627ab3

Please sign in to comment.