Skip to content

Azure/service-fabric-rs

Repository files navigation

service-fabric-rs

ci License: MIT

Service Fabric Rust Community SDK.

Build Service Fabric Reliable Services in Rust.

Service Fabric is open sourced on github: https://github.com/microsoft/service-fabric. The latest open sourced version of SF is 6.4. This SDK only provides 6.4 functionalities. New functionalities in newer versions is are not accessible in this SDK.

The Fabric runtime and client are accessible from the dlls installed from service fabric runtime. The c headers are generated from open sourced idls in repo service-fabric

This lib is developed for educational purposes, and not ready for production. Linux is not supported.

dependencies

  • service-fabric-cpp (fetched automatically by cmake) and its dependencies:
    • Install service fabric runtime. See get-started
    • Visual Studio msvc tool chain.
  • rust compiler

Quick Start/Build

Build all rust lib and examples.

cmake . -B build
cmake --build build

Build details

Setup prerequisite non-rust build dependencies

  • cmake configure cmake . -B build
    • This downloads idl files. (TODO: optimize this.)
  • cmake build cmake --build build
    • Generates fabric import libs for fabric dlls from fabric dlls installed with fabric runtime.
    • Build all rust examples.

Rust build

  • All rust targets requires fabric import libs to be built. You should always run cmake to build all on the first use of the repo. Then you can leave cmake alone and just use cargo.
  • Compile or run rust example
    • compile rust sdk cargo build
    • run sample client executable cargo run -p samples_client. source code is in crates\samples\client\src\main.rs
    • all other rust targets can be built similarly

Other targets

  • Build tcp echo service fabric singlton application (part of default build).
    • cmake --build build --target build_rust_sample_echomain
  • Test the echoapp in local cluster
    • Add app to cluster .\scripts\echomain_ctl.ps1 -Action Add
    • Run echo powershell to talk to the app .\scripts\echomain_ctl.ps1 -Action Echo
    • Remove app from cluster .\scripts\echomain_ctl.ps1 -Action Remove

Rust code generation

If you are a user of this lib you can ignore this section. Rust wrapper is generated by windows bindgen from winmd file, which is made from ClangSharp.

More dependencies

  • dotnet winget install Microsoft.DotNet.SDK.6
  • ClangSharpPInvokeGenerator dotnet tool install --global ClangSharpPInvokeGenerator --version 15.0.2

Run code generation

  • Generate winmd files only
    • cmake --build build --target generate_winmd or run dotnet build in .metadata folder
  • Generate service fabric rust sdk code only(will build generate_winmd first)
    • cmake --build build --target generate_rust or run cargo run -p tools_api

License

MIT license

Auto generated code from service fabric idl files have Microsoft MIT license.