MCPcopy
hub / github.com/containerd/containerd / Dispatch

Function Dispatch

core/images/handlers.go:156–188  ·  view source on GitHub ↗

Dispatch runs the provided handler for content specified by the descriptors. If the handler decode subresources, they will be visited, as well. Handlers for siblings are run in parallel on the provided descriptors. A handler may return `ErrSkipDesc` to signal to the dispatcher to not traverse any c

(ctx context.Context, handler Handler, limiter *semaphore.Weighted, descs ...ocispec.Descriptor)

Source from the content-addressed store, hash-verified

154//
155// If any handler returns an error, the dispatch session will be canceled.
156func Dispatch(ctx context.Context, handler Handler, limiter *semaphore.Weighted, descs ...ocispec.Descriptor) error {
157 eg, ctx2 := errgroup.WithContext(ctx)
158 for _, desc := range descs {
159 if limiter != nil {
160 if err := limiter.Acquire(ctx, 1); err != nil {
161 return err
162 }
163 }
164
165 eg.Go(func() error {
166 desc := desc
167
168 children, err := handler.Handle(ctx2, desc)
169 if limiter != nil {
170 limiter.Release(1)
171 }
172 if err != nil {
173 if errors.Is(err, ErrSkipDesc) {
174 return nil // don't traverse the children.
175 }
176 return err
177 }
178
179 if len(children) > 0 {
180 return Dispatch(ctx2, handler, limiter, children...)
181 }
182
183 return nil
184 })
185 }
186
187 return eg.Wait()
188}
189
190// ChildrenHandler decodes well-known manifest types and returns their children.
191//

Callers 5

fetchMethod · 0.92
PushContentFunction · 0.92
pullMethod · 0.92
CalculateImageUsageFunction · 0.92
unpackImageFunction · 0.92

Calls 4

AcquireMethod · 0.65
HandleMethod · 0.65
ReleaseMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…