Skip to content

Expose more types for C++; reorganized some public types a bit #2608

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

Merged
merged 2 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sdk/core/azure_core_amqp/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::str::FromStr;

use azure_core::{create_enum, create_extensible_enum};

//pub use crate::sender::error::AmqpSenderError;
use crate::{AmqpOrderedMap, AmqpSymbol, AmqpValue};

/// Type of AMQP error.
Expand Down
3 changes: 2 additions & 1 deletion sdk/core/azure_core_amqp/src/fe2o3/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::{
error::{AmqpDescribedError, AmqpErrorCondition, AmqpErrorKind},
value::AmqpSymbol,
AmqpError,
};
use std::str::FromStr;
Expand Down Expand Up @@ -62,7 +63,7 @@ impl From<&fe2o3_amqp_types::definitions::ErrorCondition> for AmqpErrorCondition
AmqpErrorCondition::from(link_error)
}
fe2o3_amqp_types::definitions::ErrorCondition::Custom(symbol) => {
AmqpErrorCondition::from(crate::AmqpSymbol::from(symbol))
AmqpErrorCondition::from(AmqpSymbol::from(symbol))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/azure_core_amqp/src/fe2o3/messaging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ pub(crate) mod message_target;
pub(crate) mod messaging_types;

use crate::{
messaging::{AmqpMessage, AmqpMessageBody},
messaging::{AmqpMessage, AmqpMessageBody, AmqpMessageProperties},
value::AmqpValue,
AmqpMessageProperties,
};

use azure_core::{error::ErrorKind, Error};
use fe2o3_amqp_types::messaging::{message::EmptyBody, IntoBody};
use serde_amqp::{extensions::TransparentVec, Value};
Expand Down
41 changes: 27 additions & 14 deletions sdk/core/azure_core_amqp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,43 @@ mod fe2o3;
#[cfg(any(not(feature = "fe2o3_amqp"), target_arch = "wasm32"))]
mod noop;

pub(crate) mod cbs;
pub(crate) mod connection;
mod cbs;
mod connection;
pub mod error;
pub(crate) mod management;
pub(crate) mod messaging;
pub(crate) mod receiver;
pub(crate) mod sender;
pub(crate) mod session;
pub(crate) mod simple_value;
pub(crate) mod value;
mod management;
mod messaging;
mod receiver;
mod sender;
mod session;
mod simple_value;
mod value;

pub use cbs::{AmqpClaimsBasedSecurity, AmqpClaimsBasedSecurityApis};
pub use connection::{AmqpConnection, AmqpConnectionApis, AmqpConnectionOptions};
pub use error::{AmqpDescribedError, AmqpError};
pub use management::{AmqpManagement, AmqpManagementApis};
pub use messaging::{
AmqpAnnotationKey, AmqpAnnotations, AmqpDelivery, AmqpDeliveryApis, AmqpMessage,
AmqpMessageBody, AmqpMessageHeader, AmqpMessageId, AmqpMessageProperties, AmqpSource,
AmqpSourceFilter, AmqpTarget,
};
pub use messaging::{AmqpDelivery, AmqpDeliveryApis, AmqpMessage, AmqpSource, AmqpTarget};
pub use receiver::{AmqpReceiver, AmqpReceiverApis, AmqpReceiverOptions, ReceiverCreditMode};
pub use sender::{AmqpSendOptions, AmqpSendOutcome, AmqpSender, AmqpSenderApis, AmqpSenderOptions};
pub use session::{AmqpSession, AmqpSessionApis, AmqpSessionOptions};
pub use simple_value::AmqpSimpleValue;
use std::fmt::Debug;
pub use value::{AmqpDescribed, AmqpList, AmqpOrderedMap, AmqpSymbol, AmqpTimestamp, AmqpValue};

pub mod builder {
pub use crate::messaging::builders::{
AmqpMessageBuilder, AmqpSourceBuilder, AmqpTargetBuilder,
};
}

pub mod message {
pub use crate::messaging::{
AmqpAnnotationKey, AmqpAnnotations, AmqpApplicationProperties, AmqpMessageBody,
AmqpMessageHeader, AmqpMessageId, AmqpMessageProperties, AmqpOutcome, AmqpSourceFilter,
DistributionMode, TerminusDurability, TerminusExpiryPolicy,
};
}

// AMQP Settle mode:
// https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-sender-settle-mode
const AMQP_SENDER_SETTLE_MODE_UNSETTLED: isize = 0;
Expand Down Expand Up @@ -73,3 +83,6 @@ pub trait Serializable {
pub trait Deserializable<T> {
fn decode(data: &[u8]) -> azure_core::Result<T>;
}

#[cfg(feature = "cplusplus")]
pub use value::{AmqpComposite, AmqpDescriptor};
4 changes: 2 additions & 2 deletions sdk/core/azure_core_amqp/src/messaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ impl AmqpMessage {
///
/// ```
/// use azure_core_amqp::AmqpMessage;
/// use azure_core_amqp::AmqpMessageBody;
/// use azure_core_amqp::message::AmqpMessageBody;
///
/// let mut message = AmqpMessage::default();
/// message.set_message_body(AmqpMessageBody::Value("Hello, world!".into()));
Expand Down Expand Up @@ -1318,7 +1318,7 @@ impl Deserializable<AmqpMessage> for AmqpMessage {
}
}

mod builders {
pub(crate) mod builders {
use super::*;

pub struct AmqpSourceBuilder {
Expand Down
14 changes: 14 additions & 0 deletions sdk/core/azure_core_amqp/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl AmqpDescribed {
}

/// An AMQP Composite type.
///
/// This is a complex type that is composed of a descriptor and a value.
/// The descriptor is used to identify the type of the value.
/// The value is the actual value.
Expand All @@ -208,20 +209,33 @@ pub struct AmqpComposite {

#[cfg(feature = "cplusplus")]
impl AmqpComposite {
/// Creates a new AMQP Composite type.
///
/// # Arguments
///
/// * `descriptor` - The descriptor of the composite type.
/// * `value` - The value of the composite type.
pub fn new(descriptor: impl Into<AmqpDescriptor>, value: impl Into<AmqpList>) -> Self {
Self {
descriptor: descriptor.into(),
value: value.into(),
}
}

/// Returns a reference to the descriptor.
pub fn descriptor(&self) -> &AmqpDescriptor {
&self.descriptor
}

/// Returns a reference to the value.
pub fn value(&self) -> &AmqpList {
&self.value
}

/// Returns a mutable reference to the value.
pub fn value_mut(&mut self) -> &mut AmqpList {
&mut self.value
}
}

#[derive(Debug, PartialEq, Clone, Default)]
Expand Down
14 changes: 10 additions & 4 deletions sdk/eventhubs/azure_messaging_eventhubs/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn send_batch_benchmark(c: &mut Criterion) {
setup();

// Check if the environment variable is set thus allowing the benchmarks to run
if azure_core_test::TestMode::current().unwrap() != azure_core_test::TestMode::Live {
if azure_core_test::TestMode::current().unwrap_or_default() != azure_core_test::TestMode::Live {
println!("Skipping benchmarks. Set AZURE_TEST_MODE to run.");
return;
}
Expand Down Expand Up @@ -73,15 +73,18 @@ fn send_batch_benchmark(c: &mut Criterion) {

criterion_group!(
name = send_batch_benchmarks;
config = Criterion::default().sample_size(100).warm_up_time(std::time::Duration::new(1, 0));
config = Criterion::default()
.sample_size(100)
.warm_up_time(std::time::Duration::new(1, 0))
.measurement_time(std::time::Duration::new(250, 0));
targets = send_batch_benchmark
);

fn send_benchmark(c: &mut Criterion) {
setup();

// Check if the environment variable is set thus allowing the benchmarks to run
if azure_core_test::TestMode::current().unwrap() != azure_core_test::TestMode::Live {
if azure_core_test::TestMode::current().unwrap_or_default() != azure_core_test::TestMode::Live {
println!("Skipping benchmarks. Set AZURE_TEST_MODE to run.");
return;
}
Expand Down Expand Up @@ -132,7 +135,10 @@ fn send_benchmark(c: &mut Criterion) {

criterion_group!(
name = send_benchmarks;
config = Criterion::default().sample_size(1000).warm_up_time(std::time::Duration::new(1, 0)).measurement_time(std::time::Duration::new(205, 0));
config = Criterion::default()
.sample_size(1000)
.warm_up_time(std::time::Duration::new(1, 0))
.measurement_time(std::time::Duration::new(2200, 0));
targets = send_benchmark
);

Expand Down
6 changes: 3 additions & 3 deletions sdk/eventhubs/azure_messaging_eventhubs/src/consumer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use azure_core::{
Uuid,
};
use azure_core_amqp::{
AmqpDescribed, AmqpManagement, AmqpManagementApis, AmqpOrderedMap, AmqpReceiver,
AmqpReceiverApis, AmqpReceiverOptions, AmqpSession, AmqpSessionApis, AmqpSource,
AmqpSourceFilter, AmqpSymbol, AmqpValue, ReceiverCreditMode,
message::AmqpSourceFilter, AmqpDescribed, AmqpManagement, AmqpManagementApis, AmqpOrderedMap,
AmqpReceiver, AmqpReceiverApis, AmqpReceiverOptions, AmqpSession, AmqpSessionApis, AmqpSource,
AmqpSymbol, AmqpValue, ReceiverCreditMode,
};
pub use event_receiver::EventReceiver;
use std::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use crate::models::{AmqpMessage, AmqpSimpleValue, AmqpValue, MessageId};
use azure_core_amqp::{AmqpAnnotationKey, AmqpMessageBody, AmqpMessageProperties};
use azure_core_amqp::message::{AmqpAnnotationKey, AmqpMessageBody, AmqpMessageProperties};
use std::{
collections::HashMap,
fmt::{Debug, Formatter},
Expand Down
4 changes: 2 additions & 2 deletions sdk/eventhubs/azure_messaging_eventhubs/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod builders {
pub use event_data::EventData;

use azure_core::Uuid;
use azure_core_amqp::AmqpMessageId;
use azure_core_amqp::message::AmqpMessageId;
use std::fmt::Debug;
use std::time::SystemTime;

Expand Down Expand Up @@ -259,7 +259,7 @@ pub(crate) struct ConsumerClientDetails {
#[cfg(test)]
mod tests {
use super::*;
use azure_core_amqp::AmqpMessageId;
use azure_core_amqp::message::AmqpMessageId;

#[test]
fn test_message_id_from_u64() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

use azure_core::http::StatusCode;
use azure_core_amqp::{AmqpError, AmqpList, AmqpMessageProperties, AmqpSimpleValue};
use azure_core_amqp::{message::AmqpMessageProperties, AmqpError, AmqpList, AmqpSimpleValue};
use azure_core_test::{recorded, TestContext};
use azure_messaging_eventhubs::{EventDataBatchOptions, ProducerClient};
use std::{env, error::Error};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All Rights reserved
// Licensed under the MIT license.

use azure_core_amqp::{AmqpList, AmqpMessageProperties};
use azure_core_amqp::{message::AmqpMessageProperties, AmqpList};
use azure_core_test::{recorded, TestContext};
use azure_messaging_eventhubs::{
models::{AmqpMessage, AmqpValue, EventData, MessageId},
Expand Down