Skip to content

Commit

Permalink
update docs on release to ockam ref ockam_v0.124.0
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user authored and metaclips committed May 29, 2024
1 parent 95235e7 commit 190c003
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 21 deletions.
2 changes: 1 addition & 1 deletion portals/kafka/warpstream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ To learn how end-to-end trust is established, please read: “[<mark style="colo

Please select an example to dig in:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><a href="warpstream.md"><mark style="color:blue;"><strong>Warpstream Cloud</strong></mark></a></td><td>Send end-to-end encrypted messages through Warpstream Cloud.</td></tr></tbody></table>
<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><a href="warpstream.md"><mark style="color:blue;"><strong>Warpstream Cloud</strong></mark></a></td><td>Send end-to-end encrypted messages through Warpstream Cloud.</td></tr></tbody></table>
18 changes: 14 additions & 4 deletions reference/libraries/rust/credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,20 @@ async fn main(ctx: Context) -> Result<()> {
DefaultAddress::ECHO_SERVICE,
&sc_listener_options.spawner_flow_control_id(),
);
let allow_production_incoming =
IncomingAbac::create_name_value(node.identities_attributes(), issuer.clone(), "cluster", "production");
let allow_production_outgoing =
OutgoingAbac::create_name_value(&ctx, node.identities_attributes(), issuer, "cluster", "production").await?;
let allow_production_incoming = IncomingAbac::create_name_value(
node.identities_attributes(),
Some(issuer.clone()),
"cluster",
"production",
);
let allow_production_outgoing = OutgoingAbac::create_name_value(
&ctx,
node.identities_attributes(),
Some(issuer),
"cluster",
"production",
)
.await?;
node.start_worker_with_access_control(
DefaultAddress::ECHO_SERVICE,
Echoer,
Expand Down
34 changes: 27 additions & 7 deletions reference/libraries/rust/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,23 @@ Add the following code to this file:

```rust
// src/relay.rs
use ockam::{Address, Any, Context, Result, Routed, Worker};
use ockam::{Any, Context, Result, Route, Routed, Worker};

pub struct Relay(pub Address);
pub struct Relay {
route: Route,
}

impl Relay {
pub fn new(route: impl Into<Route>) -> Self {
let route = route.into();

if route.is_empty() {
panic!("Relay can't forward messages to an empty route");
}

Self { route }
}
}

#[ockam::worker]
impl Worker for Relay {
Expand All @@ -360,20 +374,26 @@ impl Worker for Relay {
async fn handle_message(&mut self, ctx: &mut Context, msg: Routed<Any>) -> Result<()> {
println!("Address: {}, Received: {:?}", ctx.address(), msg);

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

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

local_message = local_message.replace_front_onward_route(&self.0)?; // Prepend predefined address to the ownward_route
local_message = local_message.pop_front_onward_route()?;
local_message = local_message.prepend_front_onward_route(&self.route); // Prepend predefined route to the onward_route

let prev_hop = local_message.return_route_ref().next()?.clone();

if let Some(info) = ctx.flow_controls().find_flow_control_with_producer_address(&self.0) {
if let Some(info) = ctx
.flow_controls()
.find_flow_control_with_producer_address(&next_on_route)
{
ctx.flow_controls()
.add_consumer(prev_hop.clone(), info.flow_control_id());
}

if let Some(info) = ctx.flow_controls().find_flow_control_with_producer_address(&prev_hop) {
ctx.flow_controls().add_consumer(self.0.clone(), info.flow_control_id());
ctx.flow_controls().add_consumer(next_on_route, info.flow_control_id());
}

// Send the message on its onward_route
Expand Down Expand Up @@ -462,8 +482,8 @@ async fn main(ctx: Context) -> Result<()> {
// Create a TCP connection to the responder node.
let connection_to_responder = tcp.connect("127.0.0.1:4000", TcpConnectionOptions::new()).await?;

// Create a Relay worker
node.start_worker("forward_to_responder", Relay(connection_to_responder.into()))
// Create and start a Relay worker
node.start_worker("forward_to_responder", Relay::new(connection_to_responder))
.await?;

// Create a TCP listener and wait for incoming connections.
Expand Down
3 changes: 2 additions & 1 deletion reference/libraries/rust/secure-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Add the following code to this file:

use hello_ockam::Relay;
use ockam::{node, Context, Result, TcpConnectionOptions, TcpListenerOptions, TcpTransportExtension};
use ockam_core::route;

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
Expand All @@ -101,7 +102,7 @@ async fn main(ctx: Context) -> Result<()> {
let connection_to_bob = tcp.connect("127.0.0.1:4000", TcpConnectionOptions::new()).await?;

// Start a Relay to forward messages to Bob using the TCP connection.
node.start_worker("forward_to_bob", Relay(connection_to_bob.into()))
node.start_worker("forward_to_bob", Relay::new(route![connection_to_bob]))
.await?;

// Create a TCP listener and wait for incoming connections.
Expand Down
34 changes: 27 additions & 7 deletions reference/protocols/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,23 @@ We'll create a worker, called `Relay`, that takes every incoming message and for
{% code lineNumbers="true" fullWidth="true" %}
```rust
// src/relay.rs
use ockam::{Address, Any, Context, Result, Routed, Worker};
use ockam::{Any, Context, Result, Route, Routed, Worker};

pub struct Relay(pub Address);
pub struct Relay {
route: Route,
}

impl Relay {
pub fn new(route: impl Into<Route>) -> Self {
let route = route.into();

if route.is_empty() {
panic!("Relay can't forward messages to an empty route");
}

Self { route }
}
}

#[ockam::worker]
impl Worker for Relay {
Expand All @@ -330,20 +344,26 @@ impl Worker for Relay {
async fn handle_message(&mut self, ctx: &mut Context, msg: Routed<Any>) -> Result<()> {
println!("Address: {}, Received: {:?}", ctx.address(), msg);

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

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

local_message = local_message.replace_front_onward_route(&self.0)?; // Prepend predefined address to the ownward_route
local_message = local_message.pop_front_onward_route()?;
local_message = local_message.prepend_front_onward_route(&self.route); // Prepend predefined route to the onward_route

let prev_hop = local_message.return_route_ref().next()?.clone();

if let Some(info) = ctx.flow_controls().find_flow_control_with_producer_address(&self.0) {
if let Some(info) = ctx
.flow_controls()
.find_flow_control_with_producer_address(&next_on_route)
{
ctx.flow_controls()
.add_consumer(prev_hop.clone(), info.flow_control_id());
}

if let Some(info) = ctx.flow_controls().find_flow_control_with_producer_address(&prev_hop) {
ctx.flow_controls().add_consumer(self.0.clone(), info.flow_control_id());
ctx.flow_controls().add_consumer(next_on_route, info.flow_control_id());
}

// Send the message on its onward_route
Expand Down Expand Up @@ -376,8 +396,8 @@ async fn main(ctx: Context) -> Result<()> {
// Create a TCP connection to the responder node.
let connection_to_responder = tcp.connect("127.0.0.1:4000", TcpConnectionOptions::new()).await?;

// Create a Relay worker
node.start_worker("forward_to_responder", Relay(connection_to_responder.into()))
// Create and start a Relay worker
node.start_worker("forward_to_responder", Relay::new(connection_to_responder))
.await?;

// Create a TCP listener and wait for incoming connections.
Expand Down
3 changes: 2 additions & 1 deletion reference/protocols/secure-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async fn main(ctx: Context) -> Result<()> {

use hello_ockam::Relay;
use ockam::{node, Context, Result, TcpConnectionOptions, TcpListenerOptions, TcpTransportExtension};
use ockam_core::route;

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
Expand All @@ -116,7 +117,7 @@ async fn main(ctx: Context) -> Result<()> {
let connection_to_bob = tcp.connect("127.0.0.1:4000", TcpConnectionOptions::new()).await?;

// Start a Relay to forward messages to Bob using the TCP connection.
node.start_worker("forward_to_bob", Relay(connection_to_bob.into()))
node.start_worker("forward_to_bob", Relay::new(route![connection_to_bob]))
.await?;

// Create a TCP listener and wait for incoming connections.
Expand Down

0 comments on commit 190c003

Please sign in to comment.