Skip to content

Commit 423d95f

Browse files
actions-usermetaclips
authored andcommitted
update docs on release to ockam ref ockam_v0.147.0
1 parent ceb5232 commit 423d95f

File tree

8 files changed

+122
-132
lines changed

8 files changed

+122
-132
lines changed

reference/libraries/rust/credentials.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async fn main(ctx: Context) -> Result<()> {
7474
let mut vault = Vault::create().await?;
7575
vault.identity_vault = identity_vault;
7676

77-
let node = Node::builder().await?.with_vault(vault).build(&ctx).await?;
77+
let node = Node::builder().await?.with_vault(vault).build(&ctx)?;
7878

7979
let issuer_identity = hex::decode("81825837830101583285f68200815820afbca9cf5d440147450f9f0d0a038a337b3fe5c17086163f2c54509558b62ef4f41a654cf97d1a7818fc7d8200815840650c4c939b96142546559aed99c52b64aa8a2f7b242b46534f7f8d0c5cc083d2c97210b93e9bca990e9cb9301acc2b634ffb80be314025f9adc870713e6fde0d").unwrap();
8080
let issuer = node.import_private_identity(None, &issuer_identity, &secret).await?;
@@ -121,7 +121,7 @@ async fn main(ctx: Context) -> Result<()> {
121121
pre_trusted_identities.insert(identifier.clone(), attributes.clone());
122122
}
123123
members
124-
.bootstrap_pre_trusted_members(&pre_trusted_identities.into())
124+
.bootstrap_pre_trusted_members(&issuer, &pre_trusted_identities.into())
125125
.await?;
126126

127127
let tcp_listener_options = TcpListenerOptions::new();
@@ -132,27 +132,25 @@ async fn main(ctx: Context) -> Result<()> {
132132
// Start a secure channel listener that only allows channels where the identity
133133
// at the other end of the channel can authenticate with the latest private key
134134
// corresponding to one of the above known public identifiers.
135-
node.create_secure_channel_listener(&issuer, DefaultAddress::SECURE_CHANNEL_LISTENER, sc_listener_options)
136-
.await?;
135+
node.create_secure_channel_listener(&issuer, DefaultAddress::SECURE_CHANNEL_LISTENER, sc_listener_options)?;
137136

138137
// Start a credential issuer worker that will only accept incoming requests from
139138
// authenticated secure channels with our known public identifiers.
140139
let allow_known = IdentityIdAccessControl::new(known_identifiers);
141140
node.flow_controls()
142-
.add_consumer(DefaultAddress::CREDENTIAL_ISSUER, &sc_listener_flow_control_id);
141+
.add_consumer(&DefaultAddress::CREDENTIAL_ISSUER.into(), &sc_listener_flow_control_id);
143142
node.start_worker_with_access_control(
144143
DefaultAddress::CREDENTIAL_ISSUER,
145144
credential_issuer,
146145
allow_known,
147146
AllowAll,
148-
)
149-
.await?;
147+
)?;
150148

151149
// Initialize TCP Transport, create a TCP listener, and wait for connections.
152-
let tcp = node.create_tcp_transport().await?;
150+
let tcp = node.create_tcp_transport()?;
153151
tcp.listen("127.0.0.1:5000", tcp_listener_options).await?;
154152

155-
// Don't call node.stop() here so this node runs forever.
153+
// Don't call node.shutdown() here so this node runs forever.
156154
println!("issuer started");
157155
Ok(())
158156
}
@@ -203,10 +201,10 @@ async fn main(ctx: Context) -> Result<()> {
203201
let mut vault = Vault::create().await?;
204202
vault.identity_vault = identity_vault;
205203

206-
let node = Node::builder().await?.with_vault(vault).build(&ctx).await?;
204+
let node = Node::builder().await?.with_vault(vault).build(&ctx)?;
207205

208206
// Initialize the TCP Transport
209-
let tcp = node.create_tcp_transport().await?;
207+
let tcp = node.create_tcp_transport()?;
210208

211209
// Create an Identity representing the server
212210
// Load an identity corresponding to the following public identifier
@@ -256,7 +254,7 @@ async fn main(ctx: Context) -> Result<()> {
256254
.as_consumer(&tcp_listener_options.spawner_flow_control_id());
257255

258256
node.flow_controls().add_consumer(
259-
DefaultAddress::ECHO_SERVICE,
257+
&DefaultAddress::ECHO_SERVICE.into(),
260258
&sc_listener_options.spawner_flow_control_id(),
261259
);
262260
let allow_production_incoming = IncomingAbac::create_name_value(
@@ -271,25 +269,22 @@ async fn main(ctx: Context) -> Result<()> {
271269
Some(issuer),
272270
"cluster",
273271
"production",
274-
)
275-
.await?;
272+
)?;
276273
node.start_worker_with_access_control(
277274
DefaultAddress::ECHO_SERVICE,
278275
Echoer,
279276
allow_production_incoming,
280277
allow_production_outgoing,
281-
)
282-
.await?;
278+
)?;
283279

284280
// Start a secure channel listener that only allows channels with
285281
// authenticated identities.
286-
node.create_secure_channel_listener(&server, DefaultAddress::SECURE_CHANNEL_LISTENER, sc_listener_options)
287-
.await?;
282+
node.create_secure_channel_listener(&server, DefaultAddress::SECURE_CHANNEL_LISTENER, sc_listener_options)?;
288283

289284
// Create a TCP listener and wait for incoming connections
290285
tcp.listen("127.0.0.1:4000", tcp_listener_options).await?;
291286

292-
// Don't call node.stop() here so this node runs forever.
287+
// Don't call node.shutdown() here so this node runs forever.
293288
println!("server started");
294289
Ok(())
295290
}
@@ -311,13 +306,14 @@ touch examples/06-credential-exchange-client.rs
311306
```rust
312307
// examples/06-credentials-exchange-client.rs
313308
use ockam::identity::{SecureChannelOptions, Vault};
314-
use ockam::tcp::{TcpConnectionOptions, TcpTransportExtension};
309+
use ockam::tcp::TcpConnectionOptions;
315310
use ockam::vault::{EdDSACurve25519SecretKey, SigningSecret, SoftwareVaultForSigning};
316311
use ockam::{route, Context, Node, Result};
317312
use ockam_api::enroll::enrollment::Enrollment;
318313
use ockam_api::nodes::NodeManager;
319314
use ockam_api::DefaultAddress;
320315
use ockam_multiaddr::MultiAddr;
316+
use ockam_transport_tcp::TcpTransportExtension;
321317

322318
#[ockam::node]
323319
async fn main(ctx: Context) -> Result<()> {
@@ -336,9 +332,9 @@ async fn main(ctx: Context) -> Result<()> {
336332
let mut vault = Vault::create().await?;
337333
vault.identity_vault = identity_vault;
338334

339-
let mut node = Node::builder().await?.with_vault(vault).build(&ctx).await?;
335+
let mut node = Node::builder().await?.with_vault(vault).build(&ctx)?;
340336
// Initialize the TCP Transport
341-
let tcp = node.create_tcp_transport().await?;
337+
let tcp = node.create_tcp_transport()?;
342338

343339
// Create an Identity representing the client
344340
// We preload the client vault with a change history and secret key corresponding to the identity identifier
@@ -400,7 +396,7 @@ async fn main(ctx: Context) -> Result<()> {
400396
.await?;
401397
println!("Received: {}", reply); // should print "Hello Ockam!"
402398

403-
node.stop().await
399+
node.shutdown().await
404400
}
405401

406402
```

reference/libraries/rust/nodes.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async fn main(ctx: Context) -> Result<()> {
5050
let mut node = node(ctx).await?;
5151

5252
// Stop the node as soon as it starts.
53-
node.stop().await
53+
node.shutdown().await
5454
}
5555

5656
```
@@ -113,7 +113,7 @@ impl Worker for Echoer {
113113
type Message = String;
114114

115115
async fn handle_message(&mut self, ctx: &mut Context, msg: Routed<String>) -> Result<()> {
116-
println!("Address: {}, Received: {:?}", ctx.address(), msg);
116+
println!("Address: {}, Received: {:?}", ctx.primary_address(), msg);
117117

118118
// Echo the message body back on its return_route.
119119
ctx.send(msg.return_route().clone(), msg.into_body()?).await
@@ -162,7 +162,7 @@ async fn main(ctx: Context) -> Result<()> {
162162
let mut node = node(ctx).await?;
163163

164164
// Start a worker, of type Echoer, at address "echoer"
165-
node.start_worker("echoer", Echoer).await?;
165+
node.start_worker("echoer", Echoer)?;
166166

167167
// Send a message to the worker at address "echoer".
168168
node.send("echoer", "Hello Ockam!".to_string()).await?;
@@ -172,7 +172,7 @@ async fn main(ctx: Context) -> Result<()> {
172172
println!("App Received: {}", reply.into_body()?); // should print "Hello Ockam!"
173173

174174
// Stop all workers, stop the node, cleanup and return.
175-
node.stop().await
175+
node.shutdown().await
176176
}
177177

178178
```

reference/libraries/rust/routing.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ impl Worker for Hop {
8888
/// This handle function takes any incoming message and forwards
8989
/// it to the next hop in it's onward route
9090
async fn handle_message(&mut self, ctx: &mut Context, msg: Routed<Any>) -> Result<()> {
91-
println!("Address: {}, Received: {:?}", ctx.address(), msg);
91+
println!("Address: {}, Received: {:?}", ctx.primary_address(), msg);
9292

9393
// Send the message to the next worker on its onward_route
94-
ctx.forward(msg.into_local_message().step_forward(&ctx.address())?)
94+
ctx.forward(msg.into_local_message().step_forward(ctx.primary_address().clone())?)
9595
.await
9696
}
9797
}
@@ -136,10 +136,10 @@ async fn main(ctx: Context) -> Result<()> {
136136
let mut node = node(ctx).await?;
137137

138138
// Start a worker, of type Echoer, at address "echoer"
139-
node.start_worker("echoer", Echoer).await?;
139+
node.start_worker("echoer", Echoer)?;
140140

141141
// Start a worker, of type Hop, at address "h1"
142-
node.start_worker("h1", Hop).await?;
142+
node.start_worker("h1", Hop)?;
143143

144144
// Send a message to the worker at address "echoer",
145145
// via the worker at address "h1"
@@ -150,7 +150,7 @@ async fn main(ctx: Context) -> Result<()> {
150150
println!("App Received: {}", reply.into_body()?); // should print "Hello Ockam!"
151151

152152
// Stop all workers, stop the node, cleanup and return.
153-
node.stop().await
153+
node.shutdown().await
154154
}
155155

156156
```
@@ -190,12 +190,12 @@ async fn main(ctx: Context) -> Result<()> {
190190
let mut node = node(ctx).await?;
191191

192192
// Start an Echoer worker at address "echoer"
193-
node.start_worker("echoer", Echoer).await?;
193+
node.start_worker("echoer", Echoer)?;
194194

195195
// Start 3 hop workers at addresses "h1", "h2" and "h3".
196-
node.start_worker("h1", Hop).await?;
197-
node.start_worker("h2", Hop).await?;
198-
node.start_worker("h3", Hop).await?;
196+
node.start_worker("h1", Hop)?;
197+
node.start_worker("h2", Hop)?;
198+
node.start_worker("h3", Hop)?;
199199

200200
// Send a message to the echoer worker via the "h1", "h2", and "h3" workers
201201
let r = route!["h1", "h2", "h3", "echoer"];
@@ -206,7 +206,7 @@ async fn main(ctx: Context) -> Result<()> {
206206
println!("App Received: {}", reply.into_body()?); // should print "Hello Ockam!"
207207

208208
// Stop all workers, stop the node, cleanup and return.
209-
node.stop().await
209+
node.shutdown().await
210210
}
211211

212212
```
@@ -250,18 +250,19 @@ async fn main(ctx: Context) -> Result<()> {
250250
let node = node(ctx).await?;
251251

252252
// Initialize the TCP Transport
253-
let tcp = node.create_tcp_transport().await?;
253+
let tcp = node.create_tcp_transport()?;
254254

255255
// Create an echoer worker
256-
node.start_worker("echoer", Echoer).await?;
256+
node.start_worker("echoer", Echoer)?;
257257

258258
// Create a TCP listener and wait for incoming connections.
259259
let listener = tcp.listen("127.0.0.1:4000", TcpListenerOptions::new()).await?;
260260

261261
// Allow access to the Echoer via TCP connections from the TCP listener
262-
node.flow_controls().add_consumer("echoer", listener.flow_control_id());
262+
node.flow_controls()
263+
.add_consumer(&"echoer".into(), listener.flow_control_id());
263264

264-
// Don't call node.stop() here so this node runs forever.
265+
// Don't call node.shutdown() here so this node runs forever.
265266
Ok(())
266267
}
267268

@@ -290,7 +291,7 @@ async fn main(ctx: Context) -> Result<()> {
290291
let mut node = node(ctx).await?;
291292

292293
// Initialize the TCP Transport.
293-
let tcp = node.create_tcp_transport().await?;
294+
let tcp = node.create_tcp_transport()?;
294295

295296
// Create a TCP connection to a different node.
296297
let connection_to_responder = tcp.connect("localhost:4000", TcpConnectionOptions::new()).await?;
@@ -303,7 +304,7 @@ async fn main(ctx: Context) -> Result<()> {
303304
println!("App Received: {}", reply); // should print "Hello Ockam!"
304305

305306
// Stop all workers, stop the node, cleanup and return.
306-
node.stop().await
307+
node.shutdown().await
307308
}
308309

309310
```
@@ -374,28 +375,27 @@ impl Worker for Relay {
374375
/// This handle function takes any incoming message and forwards
375376
/// it to the next hop in it's onward route
376377
async fn handle_message(&mut self, ctx: &mut Context, msg: Routed<Any>) -> Result<()> {
377-
println!("Address: {}, Received: {:?}", ctx.address(), msg);
378+
println!("Address: {}, Received: {:?}", ctx.primary_address(), msg);
378379

379380
let next_on_route = self.route.next()?.clone();
380381

381382
// Some type conversion
382383
let mut local_message = msg.into_local_message();
383384

384385
local_message = local_message.pop_front_onward_route()?;
385-
local_message = local_message.prepend_front_onward_route(&self.route); // Prepend predefined route to the onward_route
386+
local_message = local_message.prepend_front_onward_route(self.route.clone()); // Prepend predefined route to the onward_route
386387

387388
let prev_hop = local_message.return_route().next()?.clone();
388389

389390
if let Some(info) = ctx
390391
.flow_controls()
391392
.find_flow_control_with_producer_address(&next_on_route)
392393
{
393-
ctx.flow_controls()
394-
.add_consumer(prev_hop.clone(), info.flow_control_id());
394+
ctx.flow_controls().add_consumer(&prev_hop, info.flow_control_id());
395395
}
396396

397397
if let Some(info) = ctx.flow_controls().find_flow_control_with_producer_address(&prev_hop) {
398-
ctx.flow_controls().add_consumer(next_on_route, info.flow_control_id());
398+
ctx.flow_controls().add_consumer(&next_on_route, info.flow_control_id());
399399
}
400400

401401
// Send the message on its onward_route
@@ -437,18 +437,19 @@ async fn main(ctx: Context) -> Result<()> {
437437
let node = node(ctx).await?;
438438

439439
// Initialize the TCP Transport
440-
let tcp = node.create_tcp_transport().await?;
440+
let tcp = node.create_tcp_transport()?;
441441

442442
// Create an echoer worker
443-
node.start_worker("echoer", Echoer).await?;
443+
node.start_worker("echoer", Echoer)?;
444444

445445
// Create a TCP listener and wait for incoming connections.
446446
let listener = tcp.listen("127.0.0.1:4000", TcpListenerOptions::new()).await?;
447447

448448
// Allow access to the Echoer via TCP connections from the TCP listener
449-
node.flow_controls().add_consumer("echoer", listener.flow_control_id());
449+
node.flow_controls()
450+
.add_consumer(&"echoer".into(), listener.flow_control_id());
450451

451-
// Don't call node.stop() here so this node runs forever.
452+
// Don't call node.shutdown() here so this node runs forever.
452453
Ok(())
453454
}
454455

@@ -481,23 +482,22 @@ async fn main(ctx: Context) -> Result<()> {
481482
let node = node(ctx).await?;
482483

483484
// Initialize the TCP Transport
484-
let tcp = node.create_tcp_transport().await?;
485+
let tcp = node.create_tcp_transport()?;
485486

486487
// Create a TCP connection to the responder node.
487488
let connection_to_responder = tcp.connect("127.0.0.1:4000", TcpConnectionOptions::new()).await?;
488489

489490
// Create and start a Relay worker
490-
node.start_worker("forward_to_responder", Relay::new(connection_to_responder))
491-
.await?;
491+
node.start_worker("forward_to_responder", Relay::new(connection_to_responder))?;
492492

493493
// Create a TCP listener and wait for incoming connections.
494494
let listener = tcp.listen("127.0.0.1:3000", TcpListenerOptions::new()).await?;
495495

496496
// Allow access to the Relay via TCP connections from the TCP listener
497497
node.flow_controls()
498-
.add_consumer("forward_to_responder", listener.flow_control_id());
498+
.add_consumer(&"forward_to_responder".into(), listener.flow_control_id());
499499

500-
// Don't call node.stop() here so this node runs forever.
500+
// Don't call node.shutdown() here so this node runs forever.
501501
Ok(())
502502
}
503503

@@ -526,7 +526,7 @@ async fn main(ctx: Context) -> Result<()> {
526526
let mut node = node(ctx).await?;
527527

528528
// Initialize the TCP Transport
529-
let tcp = node.create_tcp_transport().await?;
529+
let tcp = node.create_tcp_transport()?;
530530

531531
// Create a TCP connection to the middle node.
532532
let connection_to_middle_node = tcp.connect("localhost:3000", TcpConnectionOptions::new()).await?;
@@ -538,7 +538,7 @@ async fn main(ctx: Context) -> Result<()> {
538538
println!("App Received: {}", reply); // should print "Hello Ockam!"
539539

540540
// Stop all workers, stop the node, cleanup and return.
541-
node.stop().await
541+
node.shutdown().await
542542
}
543543

544544
```

0 commit comments

Comments
 (0)