#wasmcloud #factorial #interface #capability #idl #rpc #contract

wasmcloud-interface-factorial

Interface library for the wasmcloud factorial capability, wasmcloud:example:factorial

16 releases (9 breaking)

0.10.0 Sep 19, 2023
0.9.0 Jul 20, 2023
0.8.0 Apr 12, 2023
0.7.1 Nov 23, 2022
0.2.0 Oct 24, 2021

#449 in Asynchronous

Apache-2.0 and maybe LGPL-3.0-or-later

10KB
112 lines

crates.io  TinyGo Version

wasmCloud Factorial Interface

This is the definition for the interface used for examples and illustrations with the contract ID of wasmcloud:example:factorial.

This is an interface for a simple service that calculates the factorial of a whole number.

NOTE that this is just an example, and we would not recommend a real-world production scenario where you use an interface and accompanying capability provider for factorial calculations.

Capability Provider Implementations

The following is a list of implementations of the wasmcloud:example:factorial contract. Feel free to submit a PR adding your implementation if you have a community/open source version.

Name Vendor Description
Factorial wasmCloud wasmCloud example implementation of the Factorial interface

Example Usage (🦀 Rust)

Calculate a factorial, handling the error case

use wasmbus_rpc::actor::prelude::Context;
use wasmcloud_interface_factorial::{Factorial, FactorialSender};

async fn factorial(ctx: &Context, n: u32) -> u64 {
    let factorial = FactorialSender::new();
    match factorial.calculate(ctx, &n).await {
        Ok(num) => num,
        // 0 is not a possible factorial so it's obvious that an error occurred
        Err(_e) => 0,
    }
}

Dependencies

~13–31MB
~478K SLoC