Skip to content

Commit 9b80873

Browse files
committed
some public API cleanup
1 parent eb7440a commit 9b80873

22 files changed

+80
-95
lines changed

examples/client-certificate.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use lapin::{
2-
BasicProperties, Connection, ConnectionProperties,
2+
BasicProperties, Confirmation, Connection, ConnectionProperties,
33
message::DeliveryResult,
44
options::*,
5-
publisher_confirm::Confirmation,
65
tcp::{OwnedIdentity, OwnedTLSConfig},
76
types::FieldTable,
87
};
@@ -48,7 +47,7 @@ async fn main() {
4847
let channel_a = conn.create_channel().await.expect("create_channel");
4948
//receive channel
5049
let channel_b = conn.create_channel().await.expect("create_channel");
51-
info!(state=?conn.status().state());
50+
info!(state=?conn.status());
5251

5352
//create the hello queue
5453
let queue = channel_a
@@ -59,7 +58,7 @@ async fn main() {
5958
)
6059
.await
6160
.expect("queue_declare");
62-
info!(state=?conn.status().state());
61+
info!(state=?conn.status());
6362
info!(?queue, "Declared queue");
6463

6564
info!("will consume");
@@ -81,7 +80,7 @@ async fn main() {
8180
.expect("basic_ack");
8281
}
8382
});
84-
info!(state=?conn.status().state());
83+
info!(state=?conn.status());
8584

8685
info!("will publish");
8786
let payload = b"Hello world!";
@@ -98,5 +97,5 @@ async fn main() {
9897
.await
9998
.expect("publisher-confirms");
10099
assert_eq!(confirm, Confirmation::NotRequested);
101-
info!(state=?conn.status().state());
100+
info!(state=?conn.status());
102101
}

examples/connection.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use lapin::{
2-
BasicProperties, Connection, ConnectionProperties, message::DeliveryResult, options::*,
3-
publisher_confirm::Confirmation, types::FieldTable,
2+
BasicProperties, Confirmation, Connection, ConnectionProperties, message::DeliveryResult,
3+
options::*, types::FieldTable,
44
};
55
use tracing::info;
66

@@ -25,7 +25,7 @@ fn main() {
2525
let channel_a = conn.create_channel().await.expect("create_channel");
2626
//receive channel
2727
let channel_b = conn.create_channel().await.expect("create_channel");
28-
info!(state=?conn.status().state());
28+
info!(state=?conn.status());
2929

3030
//create the hello queue
3131
let queue = channel_a
@@ -36,7 +36,7 @@ fn main() {
3636
)
3737
.await
3838
.expect("queue_declare");
39-
info!(state=?conn.status().state());
39+
info!(state=?conn.status());
4040
info!(?queue, "Declared queue");
4141

4242
info!("will consume");
@@ -66,7 +66,7 @@ fn main() {
6666
}
6767
}
6868
});
69-
info!(state=?conn.status().state());
69+
info!(state=?conn.status());
7070

7171
info!("will publish");
7272
let payload = b"Hello world!";
@@ -83,7 +83,7 @@ fn main() {
8383
.await
8484
.expect("publisher-confirms");
8585
assert_eq!(confirm, Confirmation::NotRequested);
86-
info!(state=?conn.status().state());
86+
info!(state=?conn.status());
8787
}
8888

8989
conn.run().expect("conn.run");

examples/consumer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async fn main() {
2020

2121
//receive channel
2222
let channel = conn.create_channel().await.expect("create_channel");
23-
info!(state=?conn.status().state());
23+
info!(state=?conn.status());
2424

2525
let queue = channel
2626
.queue_declare(
@@ -30,7 +30,7 @@ async fn main() {
3030
)
3131
.await
3232
.expect("queue_declare");
33-
info!(state=?conn.status().state());
33+
info!(state=?conn.status());
3434
info!(?queue, "Declared queue");
3535

3636
info!("will consume");
@@ -43,7 +43,7 @@ async fn main() {
4343
)
4444
.await
4545
.expect("basic_consume");
46-
info!(state=?conn.status().state());
46+
info!(state=?conn.status());
4747

4848
while let Some(delivery) = consumer.next().await {
4949
info!(message=?delivery, "received message");

examples/publisher_confirms.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async fn tokio_main() {
2626
let channel_a = conn.create_channel().await.expect("create_channel");
2727
//receive channel
2828
let channel_b = conn.create_channel().await.expect("create_channel");
29-
info!(state=?conn.status().state());
29+
info!(state=?conn.status());
3030

3131
//create the hello queue
3232
let queue = channel_a
@@ -37,14 +37,14 @@ async fn tokio_main() {
3737
)
3838
.await
3939
.expect("queue_declare");
40-
info!(state=?conn.status().state());
40+
info!(state=?conn.status());
4141
info!(?queue, "Declared queue");
4242

4343
channel_a
4444
.confirm_select(ConfirmSelectOptions::default())
4545
.await
4646
.expect("confirm_select");
47-
info!(state=?conn.status().state());
47+
info!(state=?conn.status());
4848
info!("Enabled publisher-confirms");
4949

5050
info!("will consume");
@@ -66,7 +66,7 @@ async fn tokio_main() {
6666
.expect("basic_ack");
6767
}
6868
});
69-
info!(state=?conn.status().state());
69+
info!(state=?conn.status());
7070

7171
info!("will publish");
7272
let payload = b"Hello world!";
@@ -84,7 +84,7 @@ async fn tokio_main() {
8484
.expect("publisher-confirms");
8585
assert!(confirm.is_ack());
8686
assert_eq!(confirm.take_message(), None);
87-
info!(state=?conn.status().state());
87+
info!(state=?conn.status());
8888

8989
for _ in 1..=2 {
9090
channel_a

examples/pubsub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use futures_lite::stream::StreamExt;
22
use lapin::{
3-
BasicProperties, Connection, ConnectionProperties, Result, options::*,
4-
publisher_confirm::Confirmation, types::FieldTable,
3+
BasicProperties, Confirmation, Connection, ConnectionProperties, Result, options::*,
4+
types::FieldTable,
55
};
66
use tracing::info;
77

examples/reconnect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use futures_lite::stream::StreamExt;
22
use lapin::{
3-
BasicProperties, Connection, ConnectionProperties, Result, options::*,
4-
publisher_confirm::Confirmation, types::FieldTable,
3+
BasicProperties, Confirmation, Connection, ConnectionProperties, Result, options::*,
4+
types::FieldTable,
55
};
66
use tracing::info;
77

src/acker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ impl Acker {
8989
Ok(true)
9090
}
9191

92+
/// True if our channel got closed or encountered an error
9293
pub fn poisoned(&self) -> bool {
9394
self.channel_killswitch.killed()
9495
}
9596

97+
/// False if poisoned or already used
9698
pub fn usable(&self) -> bool {
9799
!self.poisoned() && !self.killswitch.killed()
98100
}

src/channel.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
use crate::{
2-
BasicProperties, Configuration, Connection, ConnectionStatus, Error, ErrorKind, ExchangeKind,
3-
Promise, PromiseResolver, Result,
2+
BasicProperties, ChannelState, ChannelStatus, Configuration, Connection, ConnectionState,
3+
ConnectionStatus, Error, ErrorKind, ExchangeKind, Promise, PromiseResolver, Result,
44
acknowledgement::Acknowledgements,
5-
auth::Credentials,
65
basic_get_delivery::BasicGetDelivery,
76
channel_closer::ChannelCloser,
87
channel_receiver_state::DeliveryCause,
9-
channel_status::{ChannelState, ChannelStatus},
108
connection_closer::ConnectionCloser,
11-
connection_status::{ConnectionResolver, ConnectionState, ConnectionStep},
9+
connection_status::{ConnectionResolver, ConnectionStep},
1210
consumer::Consumer,
1311
consumers::Consumers,
1412
error_handler::ErrorHandler,
@@ -25,7 +23,10 @@ use crate::{
2523
topology::ChannelDefinition,
2624
types::*,
2725
};
28-
use amq_protocol::frame::{AMQPContentHeader, AMQPFrame};
26+
use amq_protocol::{
27+
auth::Credentials,
28+
frame::{AMQPContentHeader, AMQPFrame},
29+
};
2930
use executor_trait::FullExecutor;
3031
use std::{convert::TryFrom, fmt, sync::Arc};
3132
use tracing::{Level, error, info, level_enabled, trace};

src/channel_closer.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use crate::{
2-
channel_status::ChannelStatus, internal_rpc::InternalRPCHandle, protocol, types::ChannelId,
3-
};
1+
use crate::{ChannelStatus, internal_rpc::InternalRPCHandle, protocol, types::ChannelId};
42
use std::fmt;
53

64
pub(crate) struct ChannelCloser {

src/channel_status.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ impl ChannelStatus {
7373
inner.finalize_connection();
7474
}
7575

76-
pub fn state(&self) -> ChannelState {
77-
self.lock_inner().state
78-
}
79-
8076
pub(crate) fn set_state(&self, state: ChannelState) {
8177
self.lock_inner().state = state;
8278
}

0 commit comments

Comments
 (0)