X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/91cd750b78b39195b0e8f3328a3e7f34484172a3..8da425a41233ce425f84e0e78166ac97358a5417:/lib/controller/federation/generated.go diff --git a/lib/controller/federation/generated.go b/lib/controller/federation/generated.go index b34b9b165a..20edd90b95 100755 --- a/lib/controller/federation/generated.go +++ b/lib/controller/federation/generated.go @@ -8,17 +8,20 @@ import ( "context" "sort" "sync" + "sync/atomic" - "git.curoverse.com/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvados" ) // // -- this file is auto-generated -- do not edit -- edit list.go and run "go generate" instead -- // -func (conn *Conn) ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) { +func (conn *Conn) generated_ContainerList(ctx context.Context, options arvados.ListOptions) (arvados.ContainerList, error) { var mtx sync.Mutex var merged arvados.ContainerList + var needSort atomic.Value + needSort.Store(false) err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) { cl, err := backend.ContainerList(ctx, options) if err != nil { @@ -28,8 +31,9 @@ func (conn *Conn) ContainerList(ctx context.Context, options arvados.ListOptions defer mtx.Unlock() if len(merged.Items) == 0 { merged = cl - } else { + } else if len(cl.Items) > 0 { merged.Items = append(merged.Items, cl.Items...) + needSort.Store(true) } uuids := make([]string, 0, len(cl.Items)) for _, item := range cl.Items { @@ -37,13 +41,27 @@ func (conn *Conn) ContainerList(ctx context.Context, options arvados.ListOptions } return uuids, nil }) - sort.Slice(merged.Items, func(i, j int) bool { return merged.Items[i].UUID < merged.Items[j].UUID }) + if needSort.Load().(bool) { + // Apply the default/implied order, "modified_at desc" + sort.Slice(merged.Items, func(i, j int) bool { + mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt + return mj.Before(mi) + }) + } + if merged.Items == nil { + // Return empty results as [], not null + // (https://github.com/golang/go/issues/27589 might be + // a better solution in the future) + merged.Items = []arvados.Container{} + } return merged, err } -func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) { +func (conn *Conn) generated_SpecimenList(ctx context.Context, options arvados.ListOptions) (arvados.SpecimenList, error) { var mtx sync.Mutex var merged arvados.SpecimenList + var needSort atomic.Value + needSort.Store(false) err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) { cl, err := backend.SpecimenList(ctx, options) if err != nil { @@ -53,8 +71,9 @@ func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions) defer mtx.Unlock() if len(merged.Items) == 0 { merged = cl - } else { + } else if len(cl.Items) > 0 { merged.Items = append(merged.Items, cl.Items...) + needSort.Store(true) } uuids := make([]string, 0, len(cl.Items)) for _, item := range cl.Items { @@ -62,6 +81,58 @@ func (conn *Conn) SpecimenList(ctx context.Context, options arvados.ListOptions) } return uuids, nil }) - sort.Slice(merged.Items, func(i, j int) bool { return merged.Items[i].UUID < merged.Items[j].UUID }) + if needSort.Load().(bool) { + // Apply the default/implied order, "modified_at desc" + sort.Slice(merged.Items, func(i, j int) bool { + mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt + return mj.Before(mi) + }) + } + if merged.Items == nil { + // Return empty results as [], not null + // (https://github.com/golang/go/issues/27589 might be + // a better solution in the future) + merged.Items = []arvados.Specimen{} + } + return merged, err +} + +func (conn *Conn) generated_UserList(ctx context.Context, options arvados.ListOptions) (arvados.UserList, error) { + var mtx sync.Mutex + var merged arvados.UserList + var needSort atomic.Value + needSort.Store(false) + err := conn.splitListRequest(ctx, options, func(ctx context.Context, _ string, backend arvados.API, options arvados.ListOptions) ([]string, error) { + cl, err := backend.UserList(ctx, options) + if err != nil { + return nil, err + } + mtx.Lock() + defer mtx.Unlock() + if len(merged.Items) == 0 { + merged = cl + } else if len(cl.Items) > 0 { + merged.Items = append(merged.Items, cl.Items...) + needSort.Store(true) + } + uuids := make([]string, 0, len(cl.Items)) + for _, item := range cl.Items { + uuids = append(uuids, item.UUID) + } + return uuids, nil + }) + if needSort.Load().(bool) { + // Apply the default/implied order, "modified_at desc" + sort.Slice(merged.Items, func(i, j int) bool { + mi, mj := merged.Items[i].ModifiedAt, merged.Items[j].ModifiedAt + return mj.Before(mi) + }) + } + if merged.Items == nil { + // Return empty results as [], not null + // (https://github.com/golang/go/issues/27589 might be + // a better solution in the future) + merged.Items = []arvados.User{} + } return merged, err }