Load collects every object from metadata, topologically orders them, and installs each either real or (on failure) pseudo. The returned error is non-nil only for catastrophic conditions (nil catalog, ctx cancellation); per-object failures are recorded in degraded/trulyBroken and do not stop the load
(ctx context.Context)
| 160 | // per-object failures are recorded in degraded/trulyBroken and do not stop |
| 161 | // the loader. |
| 162 | func (l *catalogLoader) Load(ctx context.Context) error { |
| 163 | if l.cat == nil { |
| 164 | return errors.New("catalogLoader: nil catalog") |
| 165 | } |
| 166 | if l.meta == nil { |
| 167 | return nil |
| 168 | } |
| 169 | |
| 170 | objects := l.collectObjects() |
| 171 | for _, obj := range objects { |
| 172 | l.loaderObjects[obj.key()] = true |
| 173 | } |
| 174 | |
| 175 | sorted := topoSortObjects(objects) |
| 176 | for _, obj := range sorted { |
| 177 | if err := ctx.Err(); err != nil { |
| 178 | return err |
| 179 | } |
| 180 | l.installOne(obj) |
| 181 | } |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | // collectObjects flattens DatabaseSchemaMetadata into a list of objectEntry |
| 186 | // values, one per schema object the loader will install. Schemas themselves |