GetOrBuild stores resolvable into d, if the object is already resolved in the database, returns it. Otherwise it schdules the resource to be build and returns nil.
(ctx context.Context, r Resolvable)
| 64 | // in the database, returns it. Otherwise it schdules the resource to be build |
| 65 | // and returns nil. |
| 66 | func GetOrBuild(ctx context.Context, r Resolvable) (interface{}, error) { |
| 67 | id, err := Store(ctx, r) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | if Get(ctx).IsResolved(ctx, id) { |
| 72 | return Get(ctx).Resolve(ctx, id) |
| 73 | } |
| 74 | |
| 75 | newCtx := status.PutTask(keys.Clone(context.Background(), ctx), nil) |
| 76 | go func() { |
| 77 | cctx := status.PutTask(newCtx, nil) |
| 78 | Get(cctx).Resolve(cctx, id) |
| 79 | }() |
| 80 | |
| 81 | return nil, nil |
| 82 | } |
| 83 | |
| 84 | type databaseKeyTy string |
| 85 |
nothing calls this directly
no test coverage detected