rust-extensions/crates/shim-protos
Liu Jiang 43f4702b7a shim-proto: group common proto types into types
Group generated soruce files for common protobuf source files into
src/types, also simplify the build.rs.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-02-23 16:39:09 +08:00
..
examples shim-proto: add async example 2022-02-21 18:10:12 +08:00
src shim-proto: group common proto types into types 2022-02-23 16:39:09 +08:00
tests Update ttrpc-rust to 0.6 2022-01-19 08:47:43 -08:00
vendor Runc shim implementation 2022-02-17 23:02:14 +08:00
Cargo.toml shim-proto: add async example 2022-02-21 18:10:12 +08:00
README.md shim-proto: add async example 2022-02-21 18:10:12 +08:00
build.rs shim-proto: group common proto types into types 2022-02-23 16:39:09 +08:00

README.md

Shim protos and client for containerd

Crates.io docs.rs Crates.io CI

TTRPC bindings for containerd's shim events and interfaces.

Design

The containerd-shim-protos crate provides Protobuf message and TTRPC service definitions for the Containerd shim v2 protocol.

The message and service definitions are auto-generated from protobuf source files under vendor/ by using ttrpc-codegen. So please do not edit those auto-generated source files. If upgrading/modification is needed, please follow the steps:

  • Synchronize the latest protobuf source files from the upstream projects into directory 'vendor/'.
  • Re-generate the source files by cargo build --features=generate_bindings.
  • Commit the synchronized protobuf source files and auto-generated source files, keeping them in synchronization.

Usage

Add containerd-shim-client as a dependency in your Cargo.toml

[dependencies]
containerd-shim-protos = "0.1"

Basic client code looks as follows:

let client = client::Client::connect(socket_path)?;
let task_client = client::TaskClient::new(client);

let context = client::ttrpc::context::with_timeout(0);

let req = client::api::ConnectRequest {
    id: pid,
    ..Default::default()
};

let resp = task_client.connect(context, &req)?;

Example

The way to build the example:

# build sync connect, client and server
$ cargo build --example shim-proto-connect
$ sudo ./shim-proto-connect unix:///containerd-shim/shim_socket_path.sock
$ cargo build --example shim-proto-client
$ cargo build --example shim-proto-server

# build async connect, client and server
$ cargo build --example shim-proto-connect-async --features async
$ cargo build --example shim-proto-client-async --features async
$ cargo build --example shim-proto-server-async --features async