rust-extensions/crates/shim-client
Liu Jiang 8655b0ff41 shim-client: make dependency on ttrpc-codegen as optional
Now we have feature "generate_bindings" for shim-client, and crate
ttrpc-codegen is used only when feature "generate_bindings" is enabled.
So mark ttrpc-codegen as optional.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-12 22:39:30 +08:00
..
examples Add copyright headers 2021-12-10 15:14:48 -08:00
src shim-client: make dependency on ttrpc-codegen as optional 2021-12-12 22:39:30 +08:00
vendor Rename shim protos crate 2021-11-16 11:07:03 -08:00
Cargo.toml shim-client: make dependency on ttrpc-codegen as optional 2021-12-12 22:39:30 +08:00
README.md shim-client: docuement the way to upgrade the auto-generated code 2021-12-11 15:20:53 +08:00
build.rs shim-client: make dependency on ttrpc-codegen as optional 2021-12-12 22:39:30 +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-client 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-client = "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

Have a look on example here.

$ cargo build --example connect
$ sudo ./connect unix:///containerd-shim/shim_socket_path.sock