Skip to content

Releases: crossplane/function-sdk-rust

v0.4.0

Choose a tag to compare

@jonasz-lasut jonasz-lasut released this 11 Oct 16:13
fc9b0ce

Important

0.4.0 has breaking changes. Upgrade with function-sdk-rust = "0.4"; functions that use logging::configure and serve need no code changes. Check these:

  • Logs go to stderr instead of stdout, like function-sdk-go. kubectl logs shows both streams, but a log pipeline that reads only stdout loses them.
  • RUST_LOG is now honored and replaces the level selection, --debug included. It takes comma-separated target=level directives and bare levels, such as info,my_function=debug; a value with span or field filters is ignored with a warning. Check any DeploymentRuntimeConfig that already sets it.
  • --debug keeps h2, hyper, hyper_util, tonic, tower and rustls at INFO. Set RUST_LOG=debug to get their DEBUG output back.
  • Error has a new NotReady variant. An exhaustive match on function_sdk_rust::Error needs a new arm or a _ arm.

What's new

Readiness for functions that load at startup

Server is a builder for options beyond the command-line Args. serve(function, &args) is unchanged and is now shorthand for Server::new(function, &args).serve(). The first option, ready, holds the function back until a future completes: the server listens at once, but reports NOT_SERVING on the gRPC health service and answers RunFunction with UNAVAILABLE. When the future returns Ok, the function reports SERVING. If it returns an error or panics, the server shuts down and serve returns Error::NotReady. (#40)

function_sdk_rust::Server::new(function, &args)
    .ready(async move { cache.load().await })
    .serve()
    .await

Your own metrics on /metrics

Server::metrics_registry(registry) is the counterpart of function-sdk-go's WithMetricsRegistry. Register your series in a prometheus-client Registry and pass it to the server; /metrics serves them next to the grpc_server_* series. Build the registry with a prometheus-client version that is semver-compatible with the SDK's, currently 0.25. Without a registry, /metrics serves the same output as before. (#40)

let mut registry = prometheus_client::registry::Registry::default();
registry.register("evaluations", "Policy evaluations", evaluations.clone());

function_sdk_rust::Server::new(function, &args)
    .metrics_registry(registry)
    .serve()
    .await

Logging

logging::configure(debug) keeps its signature. logging::Builder adds options on top of it; the first, quiet(targets), holds more crates at INFO under --debug. (#38, #41)

function_sdk_rust::logging::Builder::new(args.debug)
    .quiet(["wasmtime", "cranelift_codegen"])
    .init();

Typed required resources

request::get_required_resources_as::<T> and request::get_required_resource_as::<T> deserialize required resources into your own types. They return Ok(None) while Crossplane has not resolved the requirement, and an error when an item does not deserialize. Integral numbers are restored before deserializing, as in resource::get. (#39)

Resource accessors

Four accessors replace the Option chains for the most common reads and writes, matching function-sdk-go's GetObservedCompositeResource, GetObservedComposedResources, SetDesiredCompositeResource and SetDesiredComposedResources. The response accessors insert an empty resource when the response has none, and otherwise modify the entry copied forward by response::to in place. (#39)

let xr: Xr = resource::get(request::observed_composite(&req))?;
let observed_bucket = request::observed_composed(&req, "bucket");
resource::update(response::desired_composed(&mut rsp, "bucket"), &bucket)?;
resource::update_status(response::desired_composite(&mut rsp), &status)?;

Fixes

  • The response::fatal doc comment said later pipeline steps may still run. Crossplane stops the pipeline at the first fatal result and applies no desired state for that reconcile; the comment now says so. (#38)

What's Changed

  • feat: add typed required resources and resource accessors by @jonasz-lasut in #39
  • fix: honor RUST_LOG in logging and fix the fatal doc by @jonasz-lasut in #38
  • feat(server): add a Server builder with readiness and metrics by @jonasz-lasut in #40
  • chore(deps): update rust crate serde_json to v1.0.154 by @renovate[bot] in #30
  • chore(deps): update dtolnay/rust-toolchain digest to 686976e by @renovate[bot] in #29
  • fix(logging): drop the env-filter feature by @jonasz-lasut in #41
  • chore(sdk): bump version to 0.4.0 by @jonasz-lasut in #42

Full Changelog: v0.3.1...v0.4.0

v0.3.1

Choose a tag to compare

@github-actions github-actions released this 08 Oct 06:37
a64ce1c

What's Changed

  • chore(deps): update rust crate prometheus-client to v0.25.1 by @renovate[bot] in #12
  • chore(deps): update softprops/action-gh-release digest to efb3536 by @renovate[bot] in #11
  • chore(deps): update dtolnay/rust-toolchain digest to 6bed076 by @renovate[bot] in #13
  • docs(governance): add maintainer/community governance docs by @jonasz-lasut in #16
  • Update README.md - add badges by @jonasz-lasut in #17
  • chore(deps): update rust crate clap to v4.6.7 by @renovate[bot] in #15
  • chore(deps): update rust docker tag to v1.99 by @renovate[bot] in #25
  • chore(deps): update dependency ubuntu to v26 by @renovate[bot] in #26
  • chore(deps): update rust crate tokio to v1.53.2 by @renovate[bot] in #23
  • chore(deps): update dependency crossplane/crossplane to v2.4.2 by @renovate[bot] in #21
  • chore(deps): update dtolnay/rust-toolchain digest to 89b1218 by @renovate[bot] in #20
  • chore(deps): update rust crate thiserror to v2.0.21 by @renovate[bot] in #22
  • chore(deps): update rust crate tokio-test to v0.4.6 by @renovate[bot] in #24
  • fix: bump rustls and move the example image to Debian 13 by @jonasz-lasut in #27
  • chore(sdk): bump version to 0.3.1 by @jonasz-lasut in #28

Full Changelog: v0.3.0...v0.3.1

v0.3.0

Choose a tag to compare

@github-actions github-actions released this 26 Aug 11:12

What's Changed

  • feat(sdk): serve any named gRPC service by @jonasz-lasut in #1
  • revert: "feat(sdk): serve any named gRPC service" by @jonasz-lasut in #4
  • chore(renovate): configure dependency updates by @jonasz-lasut in #5
  • chore(deps): pin dependencies by @renovate[bot] in #7
  • chore(deps): update actions/checkout action to v7 by @renovate[bot] in #9
  • chore(deps): update rust docker tag to v1.98 by @renovate[bot] in #8
  • feat(sdk): serve Go-compatible gRPC server metrics by @jonasz-lasut in #10

New Contributors

Full Changelog: v0.2.0...v0.3.0

v0.2.0

Choose a tag to compare

@jonasz-lasut jonasz-lasut released this 25 Aug 20:04