Skip to content

Azure/service-fabric-rs

Repository files navigation

service-fabric-rs

ci License: MIT

Service Fabric Rust 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 in alpha state, and apis are subjected to change.

dependencies

  • Install service fabric runtime. See get-started
  • rust compiler

Windows

  • Visual Studio msvc tool chain.

Linux

  • lld from llvm

dev dependencies

Quick Start/Build

Build all rust lib and examples.

cmake . -B build
cmake --build build
  • For linux, vscode devcontainer is maintained for development.

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

You can use cargo to do rust only targets.

  • 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

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 (Windows)
    • 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
  • Build tcp echo stateful service fabric single partition application (part of default build).
    • cmake --build build --target build_rust_sample_echomain_stateful

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 provided here ServiceFabric.winmd

Run code generation

  • 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

Microsoft MIT license