MCPcopy Create free account
hub / github.com/dagger/dagger / Syncer

Function Syncer

core/schema/util.go:18–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16}
17
18func Syncer[T dagql.Typed]() dagql.Field[T] {
19 return dagql.NodeFunc("sync", func(ctx context.Context, self dagql.ObjectResult[T], args struct {
20 Recipe bool `default:"false" internal:"true"`
21 }) (res dagql.Result[dagql.ID[T]], _ error) {
22 if _, ok := dagql.UnwrapAs[dagql.HasLazyEvaluation](self); ok {
23 cache, err := dagql.EngineCache(ctx)
24 if err != nil {
25 return res, err
26 }
27 if err := cache.Evaluate(ctx, self); err != nil {
28 return res, err
29 }
30 } else {
31 syncable, ok := dagql.UnwrapAs[core.Syncable](self)
32 if !ok {
33 return res, fmt.Errorf("internal error: %T does not support sync", self.Self())
34 }
35 if err := syncable.Sync(ctx); err != nil {
36 return res, err
37 }
38 }
39 var selfID *call.ID
40 var err error
41 if args.Recipe {
42 selfID, err = self.RecipeID(ctx)
43 } else {
44 selfID, err = self.ID()
45 }
46 if err != nil {
47 return res, err
48 }
49 id := dagql.NewID[T](selfID)
50 return dagql.NewResultForCurrentCall(ctx, id)
51 }).DoNotCache("sync is an operational boundary and each object already controls its own underlying lazy/cached state")
52}
53
54func collectInputsSlice[T dagql.Type](inputs []dagql.InputObject[T]) []T {
55 ts := make([]T, len(inputs))

Callers 6

InstallMethod · 0.70
InstallMethod · 0.70
InstallMethod · 0.70
InstallMethod · 0.70
InstallMethod · 0.70
InstallMethod · 0.70

Calls 9

NodeFuncFunction · 0.92
EngineCacheFunction · 0.92
NewResultForCurrentCallFunction · 0.92
DoNotCacheMethod · 0.80
SelfMethod · 0.80
EvaluateMethod · 0.65
SyncMethod · 0.65
RecipeIDMethod · 0.65
IDMethod · 0.65

Tested by

no test coverage detected