MCPcopy Create free account
hub / github.com/google/gapid / GetOrBuild

Function GetOrBuild

gapis/database/database.go:66–82  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

64// in the database, returns it. Otherwise it schdules the resource to be build
65// and returns nil.
66func 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
84type databaseKeyTy string
85

Callers

nothing calls this directly

Calls 6

BackgroundMethod · 0.80
StoreFunction · 0.70
GetFunction · 0.70
IsResolvedMethod · 0.65
ResolveMethod · 0.65
CloneMethod · 0.65

Tested by

no test coverage detected