Skip to content

Commit 6a63faa

Browse files
committed
Fix cargo workspace issues
Symlink README from root directory to eventsource-client/README.md since crates.io won't accept a README that isn't in the package directory. Add .ldrelease scripts since Releaser doesn't yet support workspaces.
1 parent de6fe27 commit 6a63faa

File tree

6 files changed

+72
-46
lines changed

6 files changed

+72
-46
lines changed

.ldrelease/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
cd eventsource-client
6+
cargo package

.ldrelease/publish-dry-run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
echo "DRY RUN: not publishing to crates.io, only copying crate"
6+
cp ./target/package/*.crate "${LD_RELEASE_ARTIFACTS_DIR}"

.ldrelease/publish.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
export CARGO_REGISTRY_TOKEN="$(cat "${LD_RELEASE_SECRETS_DIR}/rust_cratesio_api_token")"
6+
7+
cd eventsource-client
8+
cargo publish

.ldrelease/update-version.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -ue
4+
5+
sed -i "/^version\b/c version = \"${LD_RELEASE_VERSION}\"" ./eventsource-client/Cargo.toml

README.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eventsource-client/README.md

eventsource-client/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# eventsource-client
2+
3+
Client for the [Server-Sent Events] protocol (aka [EventSource]).
4+
5+
[Server-Sent Events]: https://html.spec.whatwg.org/multipage/server-sent-events.html
6+
[EventSource]: https://developer.mozilla.org/en-US/docs/Web/API/EventSource
7+
8+
## Requirements
9+
10+
Requires tokio.
11+
12+
## Usage
13+
14+
Example that just prints the type of each event received:
15+
16+
```rust
17+
use eventsource_client::Client;
18+
19+
let mut client = Client::for_url("https://example.com/stream")?
20+
.header("Authorization", "Basic username:password")?
21+
.build();
22+
23+
client.stream()
24+
.for_each(|event| {
25+
Ok(println!("got an event: {}", event.event_type))
26+
})
27+
.map_err(|e| println!("error streaming events: {:?}", e));
28+
```
29+
30+
(Some boilerplate omitted for clarity; see [examples directory] for complete,
31+
working code.)
32+
33+
[examples directory]: ../../tree/master/examples
34+
35+
## Features
36+
37+
* tokio-based streaming client.
38+
* Supports setting custom headers on the HTTP request (e.g. for endpoints
39+
requiring authorization).
40+
* Retry for failed connections.
41+
* Reconnection if connection is interrupted, with exponential backoff.
42+
43+
## Stability
44+
45+
Early stage release for feedback purposes. May contain bugs or performance
46+
issues. API subject to change.

0 commit comments

Comments
 (0)