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)
| 154 | // |
| 155 | // If any handler returns an error, the dispatch session will be canceled. |
| 156 | func 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 | // |
no test coverage detected
searching dependent graphs…