Skip to content

Commit

Permalink
feat(rust): persist application data in a database
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Nov 28, 2023
1 parent 9ac6851 commit 000a53b
Show file tree
Hide file tree
Showing 397 changed files with 13,688 additions and 11,383 deletions.
889 changes: 645 additions & 244 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/rust/example_projects/no_std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ log-semihosting = []
log-uart = []

[dependencies]
ockam = { path = "../../../../implementations/rust/ockam/ockam", default_features = false, features = ["software_vault"] }
ockam = { path = "../../../../implementations/rust/ockam/ockam", optional = true, default_features = false, features = ["software_vault"] }

alloc-cortex-m = { version = "0.4.1", optional = true }
cortex-m = { version = "0.7.2", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/example_projects/no_std/examples/01-node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use ockam::{node, Context, Result};

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Stop the node as soon as it starts.
info!("Stop the node as soon as it starts.");
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/example_projects/no_std/examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use ockam::{node, route, Context, Result};

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let mut node = node(ctx);
let mut node = node(ctx).await?;
let bob = node.create_identity().await?;

// Create a secure channel listener for Bob that will wait for requests to
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/file_transfer/examples/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Worker for FileReception {

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let node = node(ctx);
let node = node(ctx).await?;
let tcp = node.create_tcp_transport().await?;

// Create an Identity to represent Receiver.
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/file_transfer/examples/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct Opt {
async fn main(ctx: Context) -> Result<()> {
let opt = Opt::from_args();

let node = node(ctx);
let node = node(ctx).await?;
let tcp = node.create_tcp_transport().await?;

// Create an Identity to represent Sender.
Expand Down
2 changes: 2 additions & 0 deletions examples/rust/get_started/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ std = [
"serde_json/default",
"ockam_multiaddr/std",
"ockam_api/std",
"storage",
]

# Feature: "no_std" enables functionality required for platforms
Expand All @@ -27,6 +28,7 @@ no_std = ["ockam/no_std"]
# Feature: "alloc" enables support for heap allocation on "no_std"
# platforms, requires nightly.
alloc = ["ockam/alloc", "serde_json/alloc"]
storage = ["ockam_api/storage"]

[dependencies]
anyhow = "1"
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/get_started/examples/01-node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn main(ctx: Context) -> Result<()> {
print_title(vec!["Run a node & stop it right away"]);

// Create a node.
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Stop the node as soon as it starts.
node.stop().await
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/get_started/examples/02-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ockam::{node, Context, Result};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Start a worker, of type Echoer, at address "echoer"
node.start_worker("echoer", Echoer).await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/get_started/examples/03-routing-many-hops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ockam::{node, route, Context, Result};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Start an Echoer worker at address "echoer"
node.start_worker("echoer", Echoer).await?;
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/get_started/examples/03-routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ockam::{node, route, Context, Result};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Start a worker, of type Echoer, at address "echoer"
node.start_worker("echoer", Echoer).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ockam::{node, route, Context, Result, TcpConnectionOptions, TcpTransportExte
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Initialize the TCP Transport.
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ockam::{node, Context, Result, TcpListenerOptions, TcpTransportExtension};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ockam::{node, route, Context, Result, TcpConnectionOptions, TcpTransportExte
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ockam::{node, Context, Result, TcpConnectionOptions, TcpListenerOptions, Tcp
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ockam::{node, Context, Result, TcpListenerOptions, TcpTransportExtension};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ockam_transport_udp::{UdpTransportExtension, UDP};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Initialize the UDP Transport
let _udp = node.create_udp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ockam_transport_udp::UdpTransportExtension;
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the UDP Transport
let udp = node.create_udp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ockam_transport_uds::{UdsTransportExtension, UDS};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Initialize the UDS Transport
let uds = node.create_uds_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ockam_transport_uds::UdsTransportExtension;
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the UDS Transport
let uds = node.create_uds_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ockam::{node, route, Context, Result, TcpConnectionOptions, TcpTransportExte
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;

// Create an Identity to represent Alice.
let alice = node.create_identity().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ockam::{node, Context, Result, TcpConnectionOptions, TcpListenerOptions, Tcp
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ockam::{node, Context, Result, TcpListenerOptions, TcpTransportExtension};
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;

// Initialize the TCP Transport.
let tcp = node.create_tcp_transport().await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ockam_vault::{EdDSACurve25519SecretKey, SigningSecret, SoftwareVaultForSigni

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let identity_vault = SoftwareVaultForSigning::create();
let identity_vault = SoftwareVaultForSigning::create().await?;
// Import the signing secret key to the Vault
let secret = identity_vault
.import_key(SigningSecret::EdDSACurve25519(EdDSACurve25519SecretKey::new(
Expand All @@ -21,10 +21,10 @@ async fn main(ctx: Context) -> Result<()> {
.await?;

// Create a default Vault but use the signing vault with our secret in it
let mut vault = Vault::create();
let mut vault = Vault::create().await?;
vault.identity_vault = identity_vault;

let mut node = Node::builder().with_vault(vault).build(&ctx).await?;
let mut node = Node::builder().await?.with_vault(vault).build(&ctx).await?;
// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ockam_vault::{EdDSACurve25519SecretKey, SigningSecret, SoftwareVaultForSigni

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let identity_vault = SoftwareVaultForSigning::create();
let identity_vault = SoftwareVaultForSigning::create().await?;
// Import the signing secret key to the Vault
let secret = identity_vault
.import_key(SigningSecret::EdDSACurve25519(EdDSACurve25519SecretKey::new(
Expand All @@ -21,10 +21,10 @@ async fn main(ctx: Context) -> Result<()> {
.await?;

// Create a default Vault but use the signing vault with our secret in it
let mut vault = Vault::create();
let mut vault = Vault::create().await?;
vault.identity_vault = identity_vault;

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

let issuer_identity = hex::decode("81825837830101583285f68200815820afbca9cf5d440147450f9f0d0a038a337b3fe5c17086163f2c54509558b62ef4f41a654cf97d1a7818fc7d8200815840650c4c939b96142546559aed99c52b64aa8a2f7b242b46534f7f8d0c5cc083d2c97210b93e9bca990e9cb9301acc2b634ffb80be314025f9adc870713e6fde0d").unwrap();
let issuer = node.import_private_identity(None, &issuer_identity, &secret).await?;
Expand All @@ -48,14 +48,14 @@ async fn main(ctx: Context) -> Result<()> {
// For a different application this attested attribute set can be different and
// distinct for each identifier, but for this example we'll keep things simple.
let credential_issuer = CredentialsIssuer::new(
node.identities().repository(),
node.identities().identity_attributes_repository(),
node.credentials(),
&issuer,
"trust_context".into(),
);
for identifier in known_identifiers.iter() {
node.identities()
.repository()
.identity_attributes_repository()
.put_attribute_value(identifier, b"cluster".to_vec(), b"production".to_vec())
.await?;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use ockam_vault::{EdDSACurve25519SecretKey, SigningSecret, SoftwareVaultForSigni

#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let identity_vault = SoftwareVaultForSigning::create();
let identity_vault = SoftwareVaultForSigning::create().await?;
// Import the signing secret key to the Vault
let secret = identity_vault
.import_key(SigningSecret::EdDSACurve25519(EdDSACurve25519SecretKey::new(
Expand All @@ -26,10 +26,10 @@ async fn main(ctx: Context) -> Result<()> {
.await?;

// Create a default Vault but use the signing vault with our secret in it
let mut vault = Vault::create();
let mut vault = Vault::create().await?;
vault.identity_vault = identity_vault;

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

// Initialize the TCP Transport
let tcp = node.create_tcp_transport().await?;
Expand Down Expand Up @@ -90,7 +90,7 @@ async fn main(ctx: Context) -> Result<()> {
DefaultAddress::ECHO_SERVICE,
&sc_listener_options.spawner_flow_control_id(),
);
let allow_production = AbacAccessControl::create(node.identities_repository(), "cluster", "production");
let allow_production = AbacAccessControl::create(node.identity_attributes_repository(), "cluster", "production");
node.start_worker_with_access_control(DefaultAddress::ECHO_SERVICE, Echoer, allow_production, AllowAll)
.await?;

Expand Down
2 changes: 1 addition & 1 deletion examples/rust/get_started/examples/09-streams-initiator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ockam_transport_tcp::TcpTransportExtension;
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;
let tcp = node.create_tcp_transport().await?;

// Set the address of the Kafka node you created here. (e.g. "192.0.2.1:4000")
Expand Down
2 changes: 1 addition & 1 deletion examples/rust/get_started/examples/09-streams-responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ockam_transport_tcp::TcpTransportExtension;
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;
let tcp = node.create_tcp_transport().await?;

// Start an echoer worker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use ockam_transport_tcp::TcpTransportExtension;
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let mut node = node(ctx);
let mut node = node(ctx).await?;
let tcp = node.create_tcp_transport().await?;

// Set the address of the Kafka node you created here. (e.g. "192.0.2.1:4000")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ockam_transport_tcp::TcpTransportExtension;
#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
// Create a node with default implementations
let node = node(ctx);
let node = node(ctx).await?;
let tcp = node.create_tcp_transport().await?;

// Start an echoer worker
Expand Down
Loading

0 comments on commit 000a53b

Please sign in to comment.