Skip to content
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

Implementing Event Hubs SDK over AMQP 1.0 #1260

Closed
wants to merge 219 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
2cffdf6
outlined project structure
minghuaw Mar 11, 2023
861d9f2
added event hub properties
minghuaw Mar 11, 2023
eaf6008
added docs
minghuaw Mar 11, 2023
c1cfa48
added some structs
minghuaw Mar 11, 2023
a443f51
added event position
minghuaw Mar 12, 2023
888569b
added amqp_property
minghuaw Mar 12, 2023
98552d6
added annotations for amqp response
minghuaw Mar 12, 2023
ef9d400
added read event options
minghuaw Mar 13, 2023
dcecb93
added partition properties
minghuaw Mar 13, 2023
545a6bb
adding event data
minghuaw Mar 14, 2023
35ebe01
added Event
minghuaw Mar 14, 2023
fd9d102
separating event and partition event
minghuaw Mar 14, 2023
4ca8cb7
construct LastEnqueuedEventProperties
minghuaw Mar 14, 2023
f16eac7
add build amqp message from event
minghuaw Mar 15, 2023
de46f79
removed read-only property getters from Event
minghuaw Mar 15, 2023
668e22e
removed unused amqp_message_constants
minghuaw Mar 15, 2023
2871eda
partial impl of converter
minghuaw Mar 15, 2023
4472a07
renamed to create_envelope
minghuaw Mar 15, 2023
abac6fc
open connection
minghuaw Mar 16, 2023
66c5ea8
need to impl csb auth first
minghuaw Mar 20, 2023
2d73410
copying amqp_cbs_link from azservicebus
minghuaw Mar 20, 2023
393f288
copied sas auth from service bus sdk
minghuaw Mar 21, 2023
26514b0
commented out unused fields in amqp conn scope
minghuaw Apr 2, 2023
85c4e55
impl create_sending_session_and_link
minghuaw Apr 3, 2023
759ed2f
added create_receiving_session_and_link
minghuaw Apr 3, 2023
456c496
expose open_producer/consumer)_link
minghuaw Apr 3, 2023
5ce727b
added dispose and AmqpManagementLink
minghuaw Apr 3, 2023
cebd3ce
creating AmqpClient
minghuaw Apr 3, 2023
37b2fe3
need custom READ req/res messages for mgmt
minghuaw Apr 4, 2023
b96f4ed
extract initial partition properties
minghuaw Apr 4, 2023
0d625f3
impl create_producer/consumer
minghuaw Apr 4, 2023
266acfa
initial impl of event hub properties req/res
minghuaw Apr 4, 2023
f69bfbd
added PartitionPropertiesRequest
minghuaw Apr 4, 2023
78d3986
impl get_properties and get_partition_properties
minghuaw Apr 5, 2023
cf20a22
share states between AmqpConnectionScope
minghuaw Apr 6, 2023
6a1ca77
implementing event hubs connection
minghuaw Apr 6, 2023
c12ddcb
copied ServiceBusConneciontStringProperties
minghuaw Apr 6, 2023
b2d6524
modified event hubs connection string prop
minghuaw Apr 6, 2023
43082be
need to validate conn str prop
minghuaw Apr 6, 2023
8e35053
need to convert error to azure_core::Error
minghuaw Apr 6, 2023
32c9133
creating owned EH connection
minghuaw Apr 6, 2023
e039efd
removed timeout at connection openning
minghuaw Apr 7, 2023
c6225e6
impl EH connection new w/ credential
minghuaw Apr 7, 2023
a853ffb
tested EH connection using connection string
minghuaw Apr 7, 2023
5acb158
tested EH connection connection string
minghuaw Apr 7, 2023
acb6f7b
fixed bug with websockets addr
minghuaw Apr 7, 2023
deb5985
naive impl of clone_as_shared
minghuaw Apr 7, 2023
a677896
making InnerClient private
minghuaw Apr 7, 2023
cdee5c7
added is_owned & is_shared
minghuaw Apr 7, 2023
e0e5c9d
added create transport producer/consumer
minghuaw Apr 7, 2023
6e10a0b
add dispose and make close pub(crate)
minghuaw Apr 8, 2023
306717b
changed name to close_if_owned
minghuaw Apr 8, 2023
b2d5b60
impl get_pooled_producer_mut
minghuaw Apr 8, 2023
0817e7c
tested connect producer client
minghuaw Apr 8, 2023
6012762
init impl of basic_try_policy
minghuaw Apr 8, 2023
c14da8a
tested get_properties & get_partition_properties
minghuaw Apr 8, 2023
f4ff1c1
added generics RP for retry policies
minghuaw Apr 8, 2023
14dd963
initial impl of send
minghuaw Apr 8, 2023
cf538db
impl send_batch
minghuaw Apr 8, 2023
86c6450
tested send to partition
minghuaw Apr 8, 2023
51a1bce
get gateway producer if no partition id
minghuaw Apr 8, 2023
1de9587
tested sending to random partition
minghuaw Apr 8, 2023
9eaca66
added convenience methods to CreateBatchOptions
minghuaw Apr 8, 2023
0153c9e
cargo fmt
minghuaw Apr 9, 2023
a325fc7
tested create and send EventBatch
minghuaw Apr 9, 2023
00e5d3a
tested get properties and get partition properties
minghuaw Apr 9, 2023
e4d0eea
organizing namespace
minghuaw Apr 10, 2023
1b010f9
impl RecoverableTransport for AmqpConnecitonScope
minghuaw Apr 10, 2023
9603d4d
impl RecoverableTransport for EH connection
minghuaw Apr 10, 2023
1b5eac7
changed InnerClient to Sharable
minghuaw Apr 10, 2023
1f46299
separating close/dispose to Dispose trait
minghuaw Apr 10, 2023
3fc0a20
initial impl of RecoverableAmqpProducer
minghuaw Apr 11, 2023
835ee48
removed setter in favor of pub visibility
minghuaw Apr 11, 2023
837962a
recover and send share the same timeout
minghuaw Apr 11, 2023
a60a9da
tested auto-recovery
minghuaw Apr 11, 2023
7e881fa
impl try recover and mgmt ops
minghuaw Apr 11, 2023
9b0e22f
removed unused fields
minghuaw Apr 11, 2023
cbb3efe
tested managementlink recovery after idle 40 mins
minghuaw Apr 12, 2023
ea3e1bf
changed visibility
minghuaw Apr 12, 2023
8dd7667
cargo fix & fmt
minghuaw Apr 12, 2023
37eb728
added ReceivedEvent
minghuaw Apr 13, 2023
b1d4cac
adding ReceivedEvent
minghuaw Apr 13, 2023
537b98a
naive impl of receive messages
minghuaw Apr 13, 2023
57c5c0f
impl EventStream
minghuaw Apr 14, 2023
0ab16e3
set credit on first poll
minghuaw Apr 14, 2023
de7d1fa
initial impl of read from partition
minghuaw Apr 14, 2023
e0e53a5
consumer can't get anything
minghuaw Apr 14, 2023
a6a50ff
updated upstream and tested consumer
minghuaw Apr 14, 2023
e688cd7
cargo fix & fmt
minghuaw Apr 15, 2023
0403a9d
remove auth refresher upon disposing
minghuaw Apr 15, 2023
2d4985e
consumer auto recovery is bugged
minghuaw Apr 15, 2023
f8a213f
changed event stream impl
minghuaw Apr 15, 2023
ff22223
fixed recovery with next_event
minghuaw Apr 15, 2023
215c0e3
impl into_stream
minghuaw Apr 15, 2023
6c51061
exp impl stream for eventstream
minghuaw Apr 17, 2023
7e803ff
need to update consumer offset when reattaching
minghuaw Apr 17, 2023
86b3f92
fixed resuming starting from old offset
minghuaw Apr 17, 2023
fb2f29b
removed debug messages
minghuaw Apr 17, 2023
10ed769
use buffer cap as max_messages
minghuaw Apr 17, 2023
4401fac
cargo fix & fmt
minghuaw Apr 17, 2023
55d825d
removed cancellable_stream
minghuaw Apr 17, 2023
39aa674
need to impl recover multiple consumer
minghuaw Apr 17, 2023
c3f6390
need to figure out 'static lifetime issue
minghuaw Apr 17, 2023
3e7f21b
initial impl of multiple consumer recovery
minghuaw Apr 17, 2023
34cd476
changed all dispose() to close()
minghuaw Apr 18, 2023
f5f7957
added tests for read_events()
minghuaw Apr 18, 2023
248b173
need to use CancellationToken to stop stream
minghuaw Apr 18, 2023
e5f57ea
using drop future as temp workaround
minghuaw Apr 18, 2023
0f8be3e
implementing idempotent
minghuaw Apr 18, 2023
3d53a59
removing send_idempotent()
minghuaw Apr 18, 2023
90f6d48
removing unused types
minghuaw Apr 18, 2023
7527ae2
impl recv_batch
minghuaw Apr 19, 2023
c56f0fb
incorporate recovery in partition_receiver ops
minghuaw Apr 19, 2023
8be9a06
user supply max_wait_time
minghuaw Apr 19, 2023
e1208a9
tested partition receiver
minghuaw Apr 19, 2023
d3bbff5
removing invalidated consumer on partition stolen
minghuaw Apr 21, 2023
8c67eb2
renamed to from_connection_string
minghuaw Apr 21, 2023
ca0024c
added from_namespace_and_credential
minghuaw Apr 21, 2023
48e532d
renamed to EventData and ReceivedEventData
minghuaw Apr 21, 2023
357843d
need a phantom type for esti ser size w/o clone
minghuaw Apr 21, 2023
9871c2d
initial impl of amqp_phantom_message
minghuaw Apr 22, 2023
452e140
fixed problem with amqp event batch
minghuaw Apr 22, 2023
3da7951
re-org re-exports to match dotnet sdk
minghuaw Apr 23, 2023
5298028
re-export to match with dotnet sdk
minghuaw Apr 23, 2023
0792561
re-org re-exports
minghuaw Apr 23, 2023
1e4334a
organizing mods
minghuaw Apr 23, 2023
f1a61e9
removed unused
minghuaw Apr 23, 2023
f518640
derive Debug for pub types
minghuaw Apr 23, 2023
9bf2159
changed PartitionId/Key into an enum
minghuaw Apr 23, 2023
aa16694
added docs to all public types
minghuaw Apr 23, 2023
ad56881
added feature flags to integration tests
minghuaw Apr 23, 2023
7a177dc
fixed warnings in doc
minghuaw Apr 23, 2023
a658a02
clippy auto fix
minghuaw Apr 23, 2023
ed7c2e1
fixed clippy warning
minghuaw Apr 23, 2023
a5da683
fixed error in doc example
minghuaw Apr 23, 2023
77e6eeb
Merge branch 'main' into eventhubs_over_amqp
minghuaw Apr 23, 2023
06ef520
exclude crate from workspace to pass wasm test
minghuaw Apr 23, 2023
af65ba6
removed readme for github action test
minghuaw Apr 23, 2023
ba98fa4
Revert "removed readme for github action test"
minghuaw Apr 23, 2023
f74a10d
cargo readme
minghuaw Apr 23, 2023
c6bb91b
added entries for pub
minghuaw Apr 25, 2023
73b5762
fixed error in crate name in the doc
minghuaw May 1, 2023
8df68fe
fixed missing Send in trait bound
minghuaw Aug 10, 2023
71da1fb
expose BasicRetryPolicy publicly so that it can be referenced in user…
jackgerrits Aug 10, 2023
9d5538c
renamed example
minghuaw Aug 10, 2023
e5f88b2
Merge branch 'eventhubs_over_amqp' into separate_eventhubs_crate
minghuaw Aug 10, 2023
31e321f
updated the example for azeventhubs
minghuaw Aug 10, 2023
4c83a0b
Merge branch 'main' into eventhubs_over_amqp
minghuaw Aug 10, 2023
aa41cc4
Merge branch 'eventhubs_over_amqp' into separate_eventhubs_crate
minghuaw Aug 10, 2023
ff2c167
update dep and alpha versioning for test
minghuaw Aug 10, 2023
baa4b08
Updated changelog
minghuaw Aug 10, 2023
87cf9e1
set dep time to latest ver that meets rustc ver
minghuaw Aug 10, 2023
11f2c73
updated readme
minghuaw Aug 10, 2023
a452242
updated changelog
minghuaw Aug 10, 2023
df601d6
restricted IntoAzureCoreError to foreign types
minghuaw Aug 10, 2023
640a5e5
updated example
minghuaw Aug 10, 2023
f6843a8
bump up preview version to 0.1.2-beta
minghuaw Aug 10, 2023
af47368
added tests for spawned consumer
minghuaw Aug 11, 2023
de21c92
bumped up version to 0.1.2 and updated changelog
minghuaw Aug 11, 2023
ef748aa
exposed auth credential types
minghuaw Aug 30, 2023
5ea2c1b
Merge branch 'main' into eventhubs_over_amqp
minghuaw Aug 30, 2023
8d3f61d
create connection w/ pub credential types
minghuaw Aug 30, 2023
163126d
added example to read from pos
minghuaw Aug 31, 2023
884dfb9
Merge pull request #3 from jackgerrits/expose_basic_retry_policy
minghuaw Aug 31, 2023
c721cfe
Merge branch 'main' into separate_eventhubs_crate
minghuaw Aug 31, 2023
59748aa
Merge branch 'separate_eventhubs_crate' of https://github.com/minghua…
minghuaw Aug 31, 2023
88a9de3
Merge branch 'separate_eventhubs_crate' into eventhubs_over_amqp
minghuaw Aug 31, 2023
8866c66
Merge pull request #6 from minghuaw/eventhubs_over_amqp
minghuaw Aug 31, 2023
3e5194c
fixed example for azeventhubs branch
minghuaw Aug 31, 2023
6d7268c
updated changelog and bumped up version
minghuaw Aug 31, 2023
9e8e714
changed DEFAULT_SCOPE to DEFAULT_RESOURCE
minghuaw Aug 31, 2023
5f018e3
use box::pin for cbs provider future
minghuaw Aug 31, 2023
e8dc5b7
added example for azure_identity
minghuaw Aug 31, 2023
de596df
renamed example
minghuaw Aug 31, 2023
3960298
removed debug info
minghuaw Aug 31, 2023
c891084
Merge branch 'separate_eventhubs_crate' into eventhubs_over_amqp
minghuaw Aug 31, 2023
1126bff
Merge pull request #7 from minghuaw/eventhubs_over_amqp
minghuaw Aug 31, 2023
072c414
updated changelog and bumped stable version
minghuaw Aug 31, 2023
a8d0963
remove generic param from EventHubConnection
minghuaw Sep 8, 2023
a6c023c
Merge branch 'eventhubs_over_amqp' of https://github.com/minghuaw/azu…
minghuaw Sep 8, 2023
cc67d20
Merge branch 'main' into eventhubs_over_amqp
minghuaw Sep 8, 2023
b519b17
renamed constructor methods and updated example
minghuaw Sep 8, 2023
31ec770
updated readme and tests
minghuaw Sep 8, 2023
4fffd8a
Merge pull request #14 from minghuaw/eventhubs_over_amqp
minghuaw Sep 8, 2023
c5830e2
bumped up version and updated changelog
minghuaw Sep 8, 2023
6fda40a
exposing TryAddError
minghuaw Sep 9, 2023
5ca06f2
add unit test for default values
minghuaw Sep 9, 2023
ecb242a
added initial benchmark setup
minghuaw Sep 10, 2023
87c113d
Merge pull request #17 from minghuaw/eventhubs_over_amqp
minghuaw Sep 10, 2023
33dd47e
bumped version and updated changelog
minghuaw Sep 10, 2023
b9f9419
high cost of starting new stream on shared conn
minghuaw Sep 10, 2023
c2b8593
reworked sharable connection
minghuaw Sep 10, 2023
fa4fa4a
change EventStream error type to azure_core::Error
minghuaw Sep 10, 2023
f0a2d9f
changed benchmark name
minghuaw Sep 10, 2023
8202834
created type alias for event stream
minghuaw Sep 11, 2023
04a8b59
return type alias
minghuaw Sep 11, 2023
c09d923
need to figure out weird bench framework behavior
minghuaw Sep 11, 2023
1de1f5e
Merge pull request #22 from minghuaw/eventhubs_over_amqp
minghuaw Sep 11, 2023
03fa137
updated changelog and bumped up version
minghuaw Sep 11, 2023
6b3dc71
None is problematic
minghuaw Sep 11, 2023
4438898
deprecating max_wait_time
minghuaw Sep 12, 2023
cfeef8e
need to figure out what causes elapsed in bench
minghuaw Sep 12, 2023
ba0d68a
benchmark will timeout at creating consumer
minghuaw Sep 12, 2023
14774b9
benchmark streaming w/o internal buffer
minghuaw Sep 13, 2023
51de7bc
Merge pull request #23 from minghuaw/removing_internal_buffer
minghuaw Sep 13, 2023
d75b143
Merge pull request #24 from minghuaw/eventhubs_over_amqp
minghuaw Sep 13, 2023
b6dfc5f
updated changelog and bumped up version
minghuaw Sep 13, 2023
c9d3d68
merge single/multi consumer event stream into one
minghuaw Sep 15, 2023
5f0160a
removed deprecated fields
minghuaw Sep 15, 2023
279f107
change MaxRetries inner field visibility
minghuaw Sep 15, 2023
9fd3585
fixed clippy warnings
minghuaw Sep 15, 2023
6f7f911
updated docs on EventStream
minghuaw Sep 15, 2023
d324a43
added getter for max retry
minghuaw Sep 15, 2023
9b67251
fixed tests
minghuaw Sep 15, 2023
5ed6118
Merge pull request #26 from minghuaw/hide-private-types
minghuaw Sep 15, 2023
179e459
Merge branch 'main' into eventhubs_over_amqp
minghuaw Sep 15, 2023
e9ccdf8
updated azure_core and bumped up version
minghuaw Sep 15, 2023
47ea5db
Merge branch 'separate_eventhubs_crate' into eventhubs_over_amqp
minghuaw Sep 15, 2023
f833d30
updated fe2o3-amqp-ws to 0.4.0
minghuaw Sep 24, 2023
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
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ members = [
"sdk/*",
"./eng/test/mock_transport"
]
resolver = "2"

exclude = [
"sdk/messaging_eventhubs", # excluded because of wasm support
]
70 changes: 70 additions & 0 deletions sdk/messaging_eventhubs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Change log

## 0.14.4

- Removed the internal buffer from `EventStream`
- Deprecates `cache_event_count` and `max_wait_time` fields in `ReadEventOptions`

## 0.14.3

- Reworked `EventHubConnection` to have more fine-grained locks
- Changed `EventStream` error type to `azure_core::Error`
- Added type alias `SingleConsumerEventStream` and `MultiConsumerEventStream`

## 0.14.2

- Exposed `TryAddError` to public

## 0.14.1

- Renamed the following constructor methods and marked the old methods as deprecated
- `from_connection_string()` -> `new_from_connection_string()`
- `from_namespace_and_credential()` -> `new_from_credential()`
- `from_namespace_and_named_key_credential()` -> `new_from_named_key_credential()`
- `from_namespace_and_sas_credential()` -> `new_from_sas_credential()`
- Removed generic parameter `C` from `EventHubConnection`

## 0.14.0

- Fixed problem with `azure_identity` credentials
- Added example showcasing how to work with `azure_identity` credentials

## 0.14.0-alpha

- Changed version number to follow that of `azure_core`
- Changing visibility of the following to public
- `BasicRetryPolicy`,
- `mod authorization`,
- `EventHubTokenCredential`
- `SharedAccessCredential`
- `AzureNamedKeyCredential`
- `AzureSasCredential`
- Added helper function `crate::authorization::build_connection_signature_authorization_resource()`
- Added following convenience constructor methods to `EventHubConnection`, `EventHubProducerClient`, and `EventHubConsumerClient`
- `from_namespace_and_named_key_credential()`
- `from_namespace_and_sas_credential()`

## 0.1.2

### 0.1.2-beta

- Changed visibility of `IntoAzureCoreError` to `pub(crate)` and restricted its impl to only foreign
error types. All other error type natively implements `Into<azure_core::error::Error>`

### 0.1.2-alpha

- Fixed a bug where `EventStream` is not `Send` because `ClosingBoxedFuture` misses `Send` in its
trait bounds
- Changed visibility of struct `EventStream` to public
- Changed visibility of trait `IntoAzureCoreError` to public
- Updated dependency `azure_core` to `"0.13"`
- Updated dependency `time`'s version to `"<=0.3.23"`, which is the latest version that supports
rust version 1.65

## 0.1.1

- Fixed wrong crate name in the example

## 0.1.0

- Initial release
91 changes: 91 additions & 0 deletions sdk/messaging_eventhubs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[package]
name = "azeventhubs"
version = "0.15.0"
edition = "2021"
description = "An unofficial AMQP 1.0 rust client for Azure Event Hubs"
readme = "README.md"
authors = ["Minghua Wu"]
license = "MIT"
repository = "https://github.com/minghuaw/azure-sdk-for-rust/tree/separate_eventhubs_crate/sdk/messaging_eventhubs"
homepage = "https://github.com/minghuaw/azure-sdk-for-rust/tree/separate_eventhubs_crate/sdk/messaging_eventhubs"
documentation = "https://docs.rs/azeventhubs"

categories = ["api-bindings"]
keywords = ["sdk", "azure", "eventhubs", "amqp", "cloud"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
time = { version = "0.3", features = ["macros"] }
url = "2"
uuid = { version = "1", features = ["v4"] }
const_format = "0.2"
thiserror = "1"
futures-util = "0.3"
log = "0.4"
urlencoding = "2"
base64 = "0.21"
digest = "0.10"
hmac = "0.12"
sha2 = "0.10"
mockall = "0.11"
async-trait = "0.1"
rand = "0.8"
pin-project-lite = "0.2.9"
serde = "1"

# Azure dependencies
azure_core = { path = "../core", version = "0.15" }

# AMQP dependencies
fe2o3-amqp = { version = "0.8.22" }
fe2o3-amqp-types = "0.7.1"
fe2o3-amqp-management = "0.2.2"
fe2o3-amqp-cbs = "0.2"
serde_amqp = { version = "0.5.9", features = ["derive", "time"] }
fe2o3-amqp-ws = "0.4.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["rt", "macros", "sync", "time", "net"] }
tokio-util = "0.7"
timer-kit = { version = "0.1", features = ["tokio"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# Add dependency to getrandom to enable WASM support
getrandom = { version = "0.2", features = ["js"] }
tokio = { version = "1", features = ["rt", "macros"]}
tokio-util = {version = "0.7.3"}
fluvio-wasm-timer = "0.2"
timer-kit = { version = "0.1", features = ["fluvio-wasm-timer"] }
js-sys = "0.3"

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
dotenv = "0.15"
tokio = {version = "1.0", features = ["macros", "rt", "rt-multi-thread"]}
env_logger = "0.10.0"
fe2o3-amqp = { version = "0.8.21", features = ["log"] }
bytes = "1"
azure_identity = { path = "../identity" }
criterion = { version = "0.5", features = ["async_tokio"] }

[features]
default = ["native-tls"]

# CI tests related features
test_e2e = [] # This enables tests under the `sdk/messaging_eventhubs/tests` directory
test_integration = [] # TODO: this feature is not used for now

rustls = ["fe2o3-amqp/rustls", "fe2o3-amqp-ws/rustls-tls-webpki-roots"]
native-tls = ["fe2o3-amqp/native-tls", "fe2o3-amqp-ws/native-tls"]

[[bench]]
name = "bench_consumer_client_start_up"
harness = false

[[bench]]
name = "bench_event_stream_start_up"
harness = false

[[bench]]
name = "bench_event_stream"
harness = false
128 changes: 128 additions & 0 deletions sdk/messaging_eventhubs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# azeventhubs

An unofficial and experimental Azure Event Hubs client library for Rust.

This crate follows a similar structure to that of the [Azure SDK for
.Net](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventhub/Azure.Messaging.EventHubs),
and thus it should be familiar to anyone who has used the dotnet SDK. This crate is still in
development, and not all features are implemented yet.

## Examples

### Event Hub Producer Example

```rust
use azeventhubs::producer::{
EventHubProducerClient, EventHubProducerClientOptions, SendEventOptions,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut producer_client =
EventHubProducerClient::new_from_connection_string(
"<CONNECTION_STRING>", // Replace with your connection string
"<EVENT_HUB_NAME>".to_string(), // Replace with your hub name
EventHubProducerClientOptions::default()
).await?;

let partition_ids = producer_client.get_partition_ids().await?;

let event = "Hello, world to first partition!";
let options = SendEventOptions::new().with_partition_id(&partition_ids[0]);
producer_client.send_event(event, options).await?;

producer_client.close().await?;

Ok(())
}
```

### Event Hub Consumer Example

```rust
use futures_util::StreamExt;
use azeventhubs::consumer::{EventHubConsumerClient, EventHubConsumerClientOptions, EventPosition, ReadEventOptions};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a consumer client
let mut consumer_client =
EventHubConsumerClient::new_from_connection_string(
EventHubConsumerClient::DEFAULT_CONSUMER_GROUP_NAME,
"<CONNECTION_STRING>", // Replace with your connection string
"<EVENT_HUB_NAME>".to_string(), // Replace with your hub name
EventHubConsumerClientOptions::default(),
).await?;

let partition_ids = consumer_client.get_partition_ids().await?;
let starting_position = EventPosition::earliest();
let options = ReadEventOptions::default();

// Get a stream of events from the first partition
let mut stream = consumer_client
.read_events_from_partition(&partition_ids[0], starting_position, options)
.await?;

// Receive 30 events
let mut counter = 0;
while let Some(event) = stream.next().await {
let event = event?;
let body = event.body()?;
let value = std::str::from_utf8(body)?;
log::info!("{:?}", value);

log::info!("counter: {}", counter);
counter += 1;
if counter > 30 {
break;
}
}
// Close the stream
stream.close().await?;

// Close the consumer client
consumer_client.close().await?;

Ok(())
}
```

## What is implemented and what is not?

| Feature | Supported |
| ------- | --------- |
| Event Hub Connection | Yes |
| Event Hub Producer | Yes |
| Event Hub Consumer | Yes |
| Partition Receiver | Yes |
| Event Hub Buffered Producer | Not yet |
| Event Hub Processor | Not yet |
| Checkpoint Store | Not yet |

## TLS Support

Communication between a client application and an Azure Service Event Hub namespace is encrypted
using Transport Layer Security (TLS). The TLS implementation is exposed to the user through the
corresponding feature flags (please see the feature flag section below). The user should ensure
either the `rustls` or `native-tls` feature is enabled, and one and only one TLS implementation
must be enabled. Enabling both features is **not** supported and will result in an error.

The `native-tls` feature is enabled by default, and it will use the `native-tls` crate to
provide TLS support. The `rustls` feature will use the `rustls` crate and `webpki-roots` crate
to provide TLS support.

## Feature Flags

This crate supports the following feature flags:

| Feature | Description |
| ------- | ----------- |
| `default` | Enables "native-tls" feature |
| `rustls` | Enables the use of the `rustls` crate for TLS support |
| `native-tls` | Enables the use of the `native-tls` crate for TLS support |

## WebAssembly Support

WebAssembly is **NOT** supported yet.

License: MIT
Loading