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

Method stream

client/containerstore.go:82–110  ·  view source on GitHub ↗
(ctx context.Context, filters ...string)

Source from the content-addressed store, hash-verified

80var errStreamNotAvailable = errors.New("streaming api not available")
81
82func (r *remoteContainers) stream(ctx context.Context, filters ...string) ([]containers.Container, error) {
83 session, err := r.client.ListStream(ctx, &containersapi.ListContainersRequest{
84 Filters: filters,
85 })
86 if err != nil {
87 return nil, errgrpc.ToNative(err)
88 }
89 var containers []containers.Container
90 for {
91 c, err := session.Recv()
92 if err != nil {
93 if err == io.EOF {
94 return containers, nil
95 }
96 if s, ok := status.FromError(err); ok {
97 if s.Code() == codes.Unimplemented {
98 return nil, errStreamNotAvailable
99 }
100 }
101 return nil, errgrpc.ToNative(err)
102 }
103 select {
104 case <-ctx.Done():
105 return containers, ctx.Err()
106 default:
107 containers = append(containers, containerFromProto(c.Container))
108 }
109 }
110}
111
112func (r *remoteContainers) Create(ctx context.Context, container containers.Container) (containers.Container, error) {
113 created, err := r.client.Create(ctx, &containersapi.CreateContainerRequest{

Callers 1

ListMethod · 0.95

Calls 5

containerFromProtoFunction · 0.70
ListStreamMethod · 0.65
RecvMethod · 0.65
DoneMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected