github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/ext/dload/list.go (about)

     1  // Package dload implements functionality to download resources into AIS cluster from external source.
     2  /*
     3   * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package dload
     6  
     7  import "regexp"
     8  
     9  func ListJobs(regex *regexp.Regexp, onlyActive bool) (any, int, error) {
    10  	var (
    11  		respMap map[string]Job
    12  		jobs    []*dljob
    13  		req     = &request{action: actList, regex: regex, onlyActive: onlyActive}
    14  	)
    15  	if g.store != nil {
    16  		jobs = g.store.getList(req)
    17  	}
    18  	if len(jobs) == 0 {
    19  		req.okRsp(respMap)
    20  		goto ex
    21  	}
    22  	respMap = make(map[string]Job, len(jobs))
    23  	for _, dljob := range jobs {
    24  		respMap[dljob.id] = dljob.clone()
    25  	}
    26  	req.okRsp(respMap)
    27  ex:
    28  	rsp := req.response
    29  	return rsp.value, rsp.statusCode, rsp.err
    30  }