-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bumped version and updated changelog (0.12.0) (#274)
* bumped version and updated changelog * check examples in CI * Fix mismatch of txn acquistion return type (#275) * fix mismatch of return types of txn acquisition * update example * bumped version and updated changelog * check examples in CI * updated changelog * Merge branch 'chore/bump-version-update-changelog-0-12-0' of https://github.com/minghuaw/fe2o3-amqp into chore/bump-version-update-changelog-0-12-0 * Added sasl_hostname and builder hostname is not overriden by url hostname (#276) * bumped version and updated changelog * check examples in CI * updated changelog * Merge branch 'chore/bump-version-update-changelog-0-12-0' of https://github.com/minghuaw/fe2o3-amqp into chore/bump-version-update-changelog-0-12-0 * updated examples * gate example code behind cfg
- Loading branch information
Showing
21 changed files
with
141 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,71 @@ | ||
use fe2o3_amqp::{Connection, sasl_profile::SaslProfile, Session, Sender, Receiver}; | ||
use wasm_bindgen::prelude::*; | ||
use wasm_bindgen_futures::spawn_local; | ||
macro_rules! cfg_wasm32 { | ||
($($item:item)*) => { | ||
$( | ||
#[cfg(target_arch = "wasm32")] | ||
$item | ||
)* | ||
}; | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn run() { | ||
std::panic::set_hook(Box::new(console_error_panic_hook::hook)); | ||
|
||
spawn_local(async { | ||
let local_set = tokio::task::LocalSet::new(); | ||
local_set.run_until(async { | ||
use fe2o3_amqp_ws::WebSocketStream; | ||
use web_sys::console; | ||
|
||
// This example uses the Azure Service Bus as the AMQP broker because it provides | ||
// a WebSocket endpoint. | ||
let hostname = "<NAMESPACE>.servicebus.windows.net"; | ||
let sa_key_name = "<SharedAccessKeyName>"; | ||
let sa_key_value = "<SharedAccessKey>"; | ||
|
||
let ws_address = format!("wss://{sa_key_name}:{sa_key_value}@{hostname}/$servicebus/websocket"); | ||
console::log_1(&format!("Connecting to {}", ws_address).into()); | ||
let ws_stream = WebSocketStream::connect(ws_address).await.unwrap(); | ||
|
||
let mut connection = Connection::builder() | ||
.container_id("wasm-client") | ||
.scheme("amqp") | ||
.hostname(hostname) | ||
.sasl_profile(SaslProfile::Plain { | ||
username: sa_key_name.into(), | ||
password: sa_key_value.into(), | ||
}) | ||
.open_with_stream_on_local_set(ws_stream, &local_set) | ||
.await | ||
.unwrap(); | ||
console::log_1(&"Connection connected".into()); | ||
|
||
let mut session = Session::builder() | ||
.begin_on_local_set(&mut connection, &local_set).await.unwrap(); | ||
|
||
console::log_1(&"Session connected".into()); | ||
|
||
let mut sender = Sender::attach(&mut session, "wasm-sender", "q1").await.unwrap(); | ||
sender.send("message from wasm").await.unwrap(); | ||
sender.close().await.unwrap(); | ||
console::log_1(&"Sender closed".into()); | ||
|
||
let mut receiver = Receiver::attach(&mut session, "wasm-receiver", "q1").await.unwrap(); | ||
let delivery = receiver.recv::<String>().await.unwrap(); | ||
receiver.accept(&delivery).await.unwrap(); | ||
console::log_1(&format!("Received: {}", delivery.body()).into()); | ||
receiver.close().await.unwrap(); | ||
|
||
drop(session); | ||
drop(connection); | ||
|
||
console::log_1(&"Connection and session closed".into()); | ||
}).await; | ||
}) | ||
cfg_wasm32! { | ||
use fe2o3_amqp::{Connection, sasl_profile::SaslProfile, Session, Sender, Receiver}; | ||
use wasm_bindgen::prelude::*; | ||
use wasm_bindgen_futures::spawn_local; | ||
|
||
#[wasm_bindgen] | ||
pub fn run() { | ||
std::panic::set_hook(Box::new(console_error_panic_hook::hook)); | ||
|
||
spawn_local(async { | ||
let local_set = tokio::task::LocalSet::new(); | ||
local_set.run_until(async { | ||
use fe2o3_amqp_ws::WebSocketStream; | ||
use web_sys::console; | ||
|
||
// This example uses the Azure Service Bus as the AMQP broker because it provides | ||
// a WebSocket endpoint. | ||
let hostname = "<NAMESPACE>.servicebus.windows.net"; | ||
let sa_key_name = "<SharedAccessKeyName>"; | ||
let sa_key_value = "<SharedAccessKey>"; | ||
|
||
let ws_address = format!("wss://{sa_key_name}:{sa_key_value}@{hostname}/$servicebus/websocket"); | ||
console::log_1(&format!("Connecting to {}", ws_address).into()); | ||
let ws_stream = WebSocketStream::connect(ws_address).await.unwrap(); | ||
|
||
let mut connection = Connection::builder() | ||
.container_id("wasm-client") | ||
.scheme("amqp") | ||
.hostname(hostname) | ||
.sasl_profile(SaslProfile::Plain { | ||
username: sa_key_name.into(), | ||
password: sa_key_value.into(), | ||
}) | ||
.open_with_stream_on_local_set(ws_stream, &local_set) | ||
.await | ||
.unwrap(); | ||
console::log_1(&"Connection connected".into()); | ||
|
||
let mut session = Session::builder() | ||
.begin_on_local_set(&mut connection, &local_set).await.unwrap(); | ||
|
||
console::log_1(&"Session connected".into()); | ||
|
||
let mut sender = Sender::attach(&mut session, "wasm-sender", "q1").await.unwrap(); | ||
sender.send("message from wasm").await.unwrap(); | ||
sender.close().await.unwrap(); | ||
console::log_1(&"Sender closed".into()); | ||
|
||
let mut receiver = Receiver::attach(&mut session, "wasm-receiver", "q1").await.unwrap(); | ||
let delivery = receiver.recv::<String>().await.unwrap(); | ||
receiver.accept(&delivery).await.unwrap(); | ||
console::log_1(&format!("Received: {}", delivery.body()).into()); | ||
receiver.close().await.unwrap(); | ||
|
||
drop(session); | ||
drop(connection); | ||
|
||
console::log_1(&"Connection and session closed".into()); | ||
}).await; | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## 0.12.0 | ||
|
||
1. Display `InvalidType` info in `DecodeError` | ||
|
||
## 0.11.0 | ||
|
||
1. Updated deps | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.