Skip to content

rutis v0.17.0

Choose a tag to compare

@github-actions github-actions released this 26 Oct 01:21
· 2062 commits to main since this release
44291d5

rutis 0.17.0

中文 · 0.16.0 release notes

0.17.0 converges the public Rust API: a plugin is written one way, what hosts use moved to rutis::host, and a migration tool, rutis-migrate, comes with it. It also adds plugin definitions: a plugin can be handed as a value to a service in another language, which mounts it. TypeScript, Python, Go, Swift and Kotlin plugin code does not change.

Rust API

(#617, #643)

  • One way to write a plugin. impl Plugin: type Deps names the dependencies, async fn apply(&self, ctx, deps) -> rutis::Result. No BoxFuture, lifetimes or Effect; cleanups are ctx.effect(|| async move { … }).
  • One error type, rutis::Error. ? takes any standard error; err.kind() returns Option<&host::ErrorKind>; an error several parties hold is Arc<ErrorKind>. The anyhow feature converts to and from anyhow.
  • Event methods are on Ctx. ctx.on::<E>, on_sync, listen, emit, parallel, serial, waterfall(e).terminal(t), bail, with closures that need no type annotations. A waterfall's Call<E> is owned, so it can be stored or moved into another task; each further listener costs what it did in 0.16 (#644).
  • Layers. The rutis root has only the 10 names plugin authors use: Ctx, Plugin, Deps, Event, Disposer, Error, Result, Definition, service, serde. What hosts use is in rutis::host (CtxHost, DynPlugin, Key<T>, ErrorKind, diagnostics); what rutis's own crates share is in the hidden rutis::internal, with no stability promise. A snapshot locks the public surface, checked by the CI job public-api.
  • rutis-loader has 11 names at its root and the rest in the modules runtime, peer, report, edit and resolve; Builtins::register("x", P::new) takes the constructor. rutis-sdk is export_plugin!(id: "x", build: P::new).
  • The build.rs service list is removed (#647, #648): Exports::service / service_in and include_exports! are gone. Rust services are exposed only with #[rutis::service]; a type whose source you cannot change is wrapped in a type of your own, which is marked. Exports only writes TypeScript declarations, with unchanged output.
  • The migration tool rutis-migrate (first release): cargo install rutis-migrate, rutis-migrate 0.17 path/to/crate --write. It rewrites what it can and leaves a // TODO(rutis 0.17): … line where it cannot. See migrating to 0.17.

Plugin definitions

(#642, #646, design)

  • A plugin can be passed to a service as a value. In Node and Bun, the result of definePlugin (in Node, Cordis object, function and class plugins too) can be an argument or return value of a service in another language. The receiver gets a rutis::Definition and mounts it with ctx.plugin(def.at(&ctx, config)?). Each copy runs in the runtime that handed it over and sees the services where it is mounted. A Rust plugin can make one too, with Definition::new(ctx, build).
  • It ends with its source. When the row that handed the definition over (or the Rust plugin that made it) stops, every copy it mounted ends first and its cleanups finish, then the source's own cleanups run; def.ended() completes then, and at fails after that. A definition mounts only in its source's instance or further inside.
  • Keeping them is the service's business. How received definitions are kept and chosen is up to the plugin that provides the service, as in Cordis; rutis has no registry for them.
  • This release supports Rust, Node and Bun. Python, Go, Swift and Kotlin cannot hand over or receive plugin definitions yet; later releases add them. How to use them: plugin API.

Compatibility

  • Only Rust plugins and Rust hosts change code: run rutis-migrate first, then fix the rest by migrating to 0.17. Dylib plugins are rebuilt with the new SDK.
  • Plugin code in the other languages and the rutis.json format are unchanged.
  • The protocol adds the capability plugins (the reference kind plugin), used only when both ends declare it. 0.17.0 and 0.16.0 hosts and runtimes connect as before; they just cannot pass plugin definitions.
  • rutis::Error is still thrown as CordisError in other languages, and the generated TypeScript type is still CordisErrorThrown.
  • The guarantee bridge/exported-services is withdrawn with the service list, its rules merged into bridge/marked-services; core/definitions, bridge/plugin-values and loader/plugin-value-copies are new.

Packages

All of these are at 0.17.0: on crates.io rutis, rutis-macros, rutis-bridge, rutis-loader, rutis-host, rutis-sdk, rutis-dylib, rutis-dylib-meta, rutis-dylib-launcher, and rutis-migrate, released for the first time; on npm @arcships/rutis, @arcships/rutis-runtime, @arcships/rutis-bun, @arcships/rutis-host and the five platform packages; on PyPI rutis, rutis-host; the Go module github.com/arcships/rutis/go/rutis (tag go/rutis/v0.17.0); the Swift package (v0.17.0); Kotlin io.github.arcships:rutis and io.github.arcships:rutis-ksp; the rutis-host binaries on the release page.