Skip to content

Commit a9a5544

Browse files
Expose more types for C++; reorganized some public types a bit (#2608)
* Expose more types for C++; reorganized some public types a bit * CI pipeline fixes
1 parent 300714c commit a9a5544

File tree

12 files changed

+68
-32
lines changed

12 files changed

+68
-32
lines changed

sdk/core/azure_core_amqp/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::str::FromStr;
55

66
use azure_core::{create_enum, create_extensible_enum};
77

8-
//pub use crate::sender::error::AmqpSenderError;
98
use crate::{AmqpOrderedMap, AmqpSymbol, AmqpValue};
109

1110
/// Type of AMQP error.

sdk/core/azure_core_amqp/src/fe2o3/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use crate::{
55
error::{AmqpDescribedError, AmqpErrorCondition, AmqpErrorKind},
6+
value::AmqpSymbol,
67
AmqpError,
78
};
89
use std::str::FromStr;
@@ -62,7 +63,7 @@ impl From<&fe2o3_amqp_types::definitions::ErrorCondition> for AmqpErrorCondition
6263
AmqpErrorCondition::from(link_error)
6364
}
6465
fe2o3_amqp_types::definitions::ErrorCondition::Custom(symbol) => {
65-
AmqpErrorCondition::from(crate::AmqpSymbol::from(symbol))
66+
AmqpErrorCondition::from(AmqpSymbol::from(symbol))
6667
}
6768
}
6869
}

sdk/core/azure_core_amqp/src/fe2o3/messaging/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ pub(crate) mod message_target;
77
pub(crate) mod messaging_types;
88

99
use crate::{
10-
messaging::{AmqpMessage, AmqpMessageBody},
10+
messaging::{AmqpMessage, AmqpMessageBody, AmqpMessageProperties},
1111
value::AmqpValue,
12-
AmqpMessageProperties,
1312
};
13+
1414
use azure_core::{error::ErrorKind, Error};
1515
use fe2o3_amqp_types::messaging::{message::EmptyBody, IntoBody};
1616
use serde_amqp::{extensions::TransparentVec, Value};

sdk/core/azure_core_amqp/src/lib.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,43 @@ mod fe2o3;
1010
#[cfg(any(not(feature = "fe2o3_amqp"), target_arch = "wasm32"))]
1111
mod noop;
1212

13-
pub(crate) mod cbs;
14-
pub(crate) mod connection;
13+
mod cbs;
14+
mod connection;
1515
pub mod error;
16-
pub(crate) mod management;
17-
pub(crate) mod messaging;
18-
pub(crate) mod receiver;
19-
pub(crate) mod sender;
20-
pub(crate) mod session;
21-
pub(crate) mod simple_value;
22-
pub(crate) mod value;
16+
mod management;
17+
mod messaging;
18+
mod receiver;
19+
mod sender;
20+
mod session;
21+
mod simple_value;
22+
mod value;
2323

2424
pub use cbs::{AmqpClaimsBasedSecurity, AmqpClaimsBasedSecurityApis};
2525
pub use connection::{AmqpConnection, AmqpConnectionApis, AmqpConnectionOptions};
2626
pub use error::{AmqpDescribedError, AmqpError};
2727
pub use management::{AmqpManagement, AmqpManagementApis};
28-
pub use messaging::{
29-
AmqpAnnotationKey, AmqpAnnotations, AmqpDelivery, AmqpDeliveryApis, AmqpMessage,
30-
AmqpMessageBody, AmqpMessageHeader, AmqpMessageId, AmqpMessageProperties, AmqpSource,
31-
AmqpSourceFilter, AmqpTarget,
32-
};
28+
pub use messaging::{AmqpDelivery, AmqpDeliveryApis, AmqpMessage, AmqpSource, AmqpTarget};
3329
pub use receiver::{AmqpReceiver, AmqpReceiverApis, AmqpReceiverOptions, ReceiverCreditMode};
3430
pub use sender::{AmqpSendOptions, AmqpSendOutcome, AmqpSender, AmqpSenderApis, AmqpSenderOptions};
3531
pub use session::{AmqpSession, AmqpSessionApis, AmqpSessionOptions};
3632
pub use simple_value::AmqpSimpleValue;
3733
use std::fmt::Debug;
3834
pub use value::{AmqpDescribed, AmqpList, AmqpOrderedMap, AmqpSymbol, AmqpTimestamp, AmqpValue};
3935

36+
pub mod builder {
37+
pub use crate::messaging::builders::{
38+
AmqpMessageBuilder, AmqpSourceBuilder, AmqpTargetBuilder,
39+
};
40+
}
41+
42+
pub mod message {
43+
pub use crate::messaging::{
44+
AmqpAnnotationKey, AmqpAnnotations, AmqpApplicationProperties, AmqpMessageBody,
45+
AmqpMessageHeader, AmqpMessageId, AmqpMessageProperties, AmqpOutcome, AmqpSourceFilter,
46+
DistributionMode, TerminusDurability, TerminusExpiryPolicy,
47+
};
48+
}
49+
4050
// AMQP Settle mode:
4151
// https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-transport-v1.0-os.html#type-sender-settle-mode
4252
const AMQP_SENDER_SETTLE_MODE_UNSETTLED: isize = 0;
@@ -73,3 +83,6 @@ pub trait Serializable {
7383
pub trait Deserializable<T> {
7484
fn decode(data: &[u8]) -> azure_core::Result<T>;
7585
}
86+
87+
#[cfg(feature = "cplusplus")]
88+
pub use value::{AmqpComposite, AmqpDescriptor};

sdk/core/azure_core_amqp/src/messaging.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ impl AmqpMessage {
11691169
///
11701170
/// ```
11711171
/// use azure_core_amqp::AmqpMessage;
1172-
/// use azure_core_amqp::AmqpMessageBody;
1172+
/// use azure_core_amqp::message::AmqpMessageBody;
11731173
///
11741174
/// let mut message = AmqpMessage::default();
11751175
/// message.set_message_body(AmqpMessageBody::Value("Hello, world!".into()));
@@ -1318,7 +1318,7 @@ impl Deserializable<AmqpMessage> for AmqpMessage {
13181318
}
13191319
}
13201320

1321-
mod builders {
1321+
pub(crate) mod builders {
13221322
use super::*;
13231323

13241324
pub struct AmqpSourceBuilder {

sdk/core/azure_core_amqp/src/value.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ impl AmqpDescribed {
196196
}
197197

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

209210
#[cfg(feature = "cplusplus")]
210211
impl AmqpComposite {
212+
/// Creates a new AMQP Composite type.
213+
///
214+
/// # Arguments
215+
///
216+
/// * `descriptor` - The descriptor of the composite type.
217+
/// * `value` - The value of the composite type.
211218
pub fn new(descriptor: impl Into<AmqpDescriptor>, value: impl Into<AmqpList>) -> Self {
212219
Self {
213220
descriptor: descriptor.into(),
214221
value: value.into(),
215222
}
216223
}
217224

225+
/// Returns a reference to the descriptor.
218226
pub fn descriptor(&self) -> &AmqpDescriptor {
219227
&self.descriptor
220228
}
221229

230+
/// Returns a reference to the value.
222231
pub fn value(&self) -> &AmqpList {
223232
&self.value
224233
}
234+
235+
/// Returns a mutable reference to the value.
236+
pub fn value_mut(&mut self) -> &mut AmqpList {
237+
&mut self.value
238+
}
225239
}
226240

227241
#[derive(Debug, PartialEq, Clone, Default)]

sdk/eventhubs/azure_messaging_eventhubs/benches/benchmarks.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn send_batch_benchmark(c: &mut Criterion) {
2727
setup();
2828

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

7474
criterion_group!(
7575
name = send_batch_benchmarks;
76-
config = Criterion::default().sample_size(100).warm_up_time(std::time::Duration::new(1, 0));
76+
config = Criterion::default()
77+
.sample_size(100)
78+
.warm_up_time(std::time::Duration::new(1, 0))
79+
.measurement_time(std::time::Duration::new(250, 0));
7780
targets = send_batch_benchmark
7881
);
7982

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

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

133136
criterion_group!(
134137
name = send_benchmarks;
135-
config = Criterion::default().sample_size(1000).warm_up_time(std::time::Duration::new(1, 0)).measurement_time(std::time::Duration::new(205, 0));
138+
config = Criterion::default()
139+
.sample_size(1000)
140+
.warm_up_time(std::time::Duration::new(1, 0))
141+
.measurement_time(std::time::Duration::new(2200, 0));
136142
targets = send_benchmark
137143
);
138144

sdk/eventhubs/azure_messaging_eventhubs/src/consumer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use azure_core::{
1919
Uuid,
2020
};
2121
use azure_core_amqp::{
22-
AmqpDescribed, AmqpManagement, AmqpManagementApis, AmqpOrderedMap, AmqpReceiver,
23-
AmqpReceiverApis, AmqpReceiverOptions, AmqpSession, AmqpSessionApis, AmqpSource,
24-
AmqpSourceFilter, AmqpSymbol, AmqpValue, ReceiverCreditMode,
22+
message::AmqpSourceFilter, AmqpDescribed, AmqpManagement, AmqpManagementApis, AmqpOrderedMap,
23+
AmqpReceiver, AmqpReceiverApis, AmqpReceiverOptions, AmqpSession, AmqpSessionApis, AmqpSource,
24+
AmqpSymbol, AmqpValue, ReceiverCreditMode,
2525
};
2626
pub use event_receiver::EventReceiver;
2727
use std::{

sdk/eventhubs/azure_messaging_eventhubs/src/models/event_data.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
14
use crate::models::{AmqpMessage, AmqpSimpleValue, AmqpValue, MessageId};
2-
use azure_core_amqp::{AmqpAnnotationKey, AmqpMessageBody, AmqpMessageProperties};
5+
use azure_core_amqp::message::{AmqpAnnotationKey, AmqpMessageBody, AmqpMessageProperties};
36
use std::{
47
collections::HashMap,
58
fmt::{Debug, Formatter},

sdk/eventhubs/azure_messaging_eventhubs/src/models/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub mod builders {
3030
pub use event_data::EventData;
3131

3232
use azure_core::Uuid;
33-
use azure_core_amqp::AmqpMessageId;
33+
use azure_core_amqp::message::AmqpMessageId;
3434
use std::fmt::Debug;
3535
use std::time::SystemTime;
3636

@@ -259,7 +259,7 @@ pub(crate) struct ConsumerClientDetails {
259259
#[cfg(test)]
260260
mod tests {
261261
use super::*;
262-
use azure_core_amqp::AmqpMessageId;
262+
use azure_core_amqp::message::AmqpMessageId;
263263

264264
#[test]
265265
fn test_message_id_from_u64() {

sdk/eventhubs/azure_messaging_eventhubs/tests/eventhubs_producer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
use azure_core::http::StatusCode;
5-
use azure_core_amqp::{AmqpError, AmqpList, AmqpMessageProperties, AmqpSimpleValue};
5+
use azure_core_amqp::{message::AmqpMessageProperties, AmqpError, AmqpList, AmqpSimpleValue};
66
use azure_core_test::{recorded, TestContext};
77
use azure_messaging_eventhubs::{EventDataBatchOptions, ProducerClient};
88
use std::{env, error::Error};

sdk/eventhubs/azure_messaging_eventhubs/tests/eventhubs_round_trip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All Rights reserved
22
// Licensed under the MIT license.
33

4-
use azure_core_amqp::{AmqpList, AmqpMessageProperties};
4+
use azure_core_amqp::{message::AmqpMessageProperties, AmqpList};
55
use azure_core_test::{recorded, TestContext};
66
use azure_messaging_eventhubs::{
77
models::{AmqpMessage, AmqpValue, EventData, MessageId},

0 commit comments

Comments
 (0)