Skip to content

Commit 03010b5

Browse files
author
“ramfox”
committed
adjust examples to new RouterBuilder::spawn api
1 parent b2bcc96 commit 03010b5

File tree

6 files changed

+11
-21
lines changed

6 files changed

+11
-21
lines changed

src/app/docs/concepts/router/page.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ async fn main() -> Result<()> {
2727
// identified by its ALPN. Spawn the router to start listening.
2828
let router = Router::builder(endpoint)
2929
.accept(iroh_blobs::ALPN, blobs)
30-
.spawn()
31-
.await?;
30+
.spawn();
3231

3332
// get our own address. At this point we have a running router
3433
// that's ready to accept connections.
@@ -46,4 +45,4 @@ async fn main() -> Result<()> {
4645
}
4746
```
4847

49-
You can add whatever protocols you need to the router, multiplexing them all over the same endpoint.
48+
You can add whatever protocols you need to the router, multiplexing them all over the same endpoint.

src/app/docs/examples/gossip-chat/page.mdx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ async fn main() -> Result<()> {
118118
// protocol.
119119
let router = Router::builder(endpoint.clone())
120120
.accept(iroh_gossip::ALPN, gossip.clone())
121-
.spawn()
122-
.await?;
121+
.spawn();
123122

124123
// Cleanly shutdown the router.
125124
router.shutdown().await?;
@@ -147,8 +146,7 @@ async fn main() -> Result<()> {
147146

148147
let router = Router::builder(endpoint.clone())
149148
.accept(iroh_gossip::ALPN, gossip.clone())
150-
.spawn()
151-
.await?;
149+
.spawn();
152150

153151
// Create a new topic.
154152
let id = TopicId::from_bytes(rand::random());
@@ -342,8 +340,7 @@ async fn main() -> Result<()> {
342340

343341
let router = Router::builder(endpoint.clone())
344342
.accept(iroh_gossip::ALPN, gossip.clone())
345-
.spawn()
346-
.await?;
343+
.spawn();
347344

348345
let id = TopicId::from_bytes(rand::random());
349346
let node_ids = vec![];
@@ -599,8 +596,7 @@ async fn main() -> Result<()> {
599596

600597
let router = Router::builder(endpoint.clone())
601598
.accept(iroh_gossip::ALPN, gossip.clone())
602-
.spawn()
603-
.await?;
599+
.spawn();
604600

605601
// in our main file, after we create a topic `id`:
606602
// print a ticket that includes our own node id and endpoint addresses

src/app/docs/protocols/writing/page.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ async fn start_accept_side() -> anyhow::Result<iroh::protocol::Router> {
3939
let endpoint = iroh::Endpoint::builder().discovery_n0().bind().await?;
4040

4141
let router = iroh::protocol::Router::builder(endpoint)
42-
.spawn()
43-
.await?;
42+
.spawn();
4443

4544
Ok(router)
4645
}
@@ -102,8 +101,7 @@ async fn start_accept_side() -> anyhow::Result<iroh::protocol::Router> {
102101

103102
let router = iroh::protocol::Router::builder(endpoint)
104103
.accept(ALPN, Echo) // This makes the router handle incoming connections with our ALPN via Echo::accept!
105-
.spawn()
106-
.await?;
104+
.spawn();
107105

108106
Ok(router)
109107
}

src/app/docs/quickstart/page.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ async fn main() -> anyhow::Result<()> {
123123
// to the blobs protocol.
124124
let router = Router::builder(endpoint)
125125
.accept(iroh_blobs::ALPN, blobs.clone())
126-
.spawn()
127-
.await?;
126+
.spawn();
128127

129128
// do *something*
130129

src/app/docs/tour/4-protocols/page.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ async fn main() -> anyhow::Result<()> {
2929
// build the router
3030
let router = Router::builder(endpoint)
3131
.accept(iroh_blobs::ALPN, blobs.clone())
32-
.spawn()
33-
.await?;
32+
.spawn();
3433

3534
router.shutdown().await?;
3635

src/app/docs/tour/5-routers/page.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ async fn main() -> anyhow::Result<()> {
2929
let router = Router::builder(endpoint)
3030
.accept(iroh_blobs::ALPN, blobs.clone())
3131
.accept(iroh_gossip::ALPN, gossip.clone())
32-
.spawn()
33-
.await?;
32+
.spawn();
3433

3534
router.shutdown().await?;
3635
Ok(())

0 commit comments

Comments
 (0)