MCPcopy Index your code
hub / github.com/containerd/containerd / NewTaskClient

Function NewTaskClient

core/runtime/v2/bridge.go:65–86  ·  view source on GitHub ↗

NewTaskClient returns a new task client interface which handles both GRPC and TTRPC servers depending on the client object type passed in. Supported client types are: - *ttrpc.Client - grpc.ClientConnInterface Currently supported servers: - TTRPC v2 (compatibility with shims before 2.0) - TTRPC v3

(client any, version int)

Source from the content-addressed store, hash-verified

63// - TTRPC v3
64// - GRPC v3
65func NewTaskClient(client any, version int) (TaskServiceClient, error) {
66 switch c := client.(type) {
67 case *ttrpc.Client:
68 switch version {
69 case 2:
70 return &ttrpcV2Bridge{client: v2.NewTTRPCTaskClient(c)}, nil
71 case 3:
72 return api.NewTTRPCTaskClient(c), nil
73 default:
74 return nil, fmt.Errorf("containerd client supports only v2 and v3 TTRPC task client (got %d)", version)
75 }
76
77 case grpc.ClientConnInterface:
78 if version != 3 {
79 return nil, fmt.Errorf("containerd client supports only v3 GRPC task service (got %d)", version)
80 }
81
82 return &grpcV3Bridge{api.NewTaskClient(c)}, nil
83 default:
84 return nil, fmt.Errorf("unsupported shim client type %T", c)
85 }
86}
87
88// ttrpcV2Bridge is a bridge from TTRPC v2 task service.
89type ttrpcV2Bridge struct {

Callers 1

newShimTaskFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…