ObjectStores is used to retrieve a list of bucket statuses
(opts ...ObjectOpt)
| 1390 | |
| 1391 | // ObjectStores is used to retrieve a list of bucket statuses |
| 1392 | func (js *js) ObjectStores(opts ...ObjectOpt) <-chan ObjectStoreStatus { |
| 1393 | var o objOpts |
| 1394 | for _, opt := range opts { |
| 1395 | if opt != nil { |
| 1396 | if err := opt.configureObject(&o); err != nil { |
| 1397 | return nil |
| 1398 | } |
| 1399 | } |
| 1400 | } |
| 1401 | ch := make(chan ObjectStoreStatus) |
| 1402 | var cancel context.CancelFunc |
| 1403 | if o.ctx == nil { |
| 1404 | o.ctx, cancel = context.WithTimeout(context.Background(), defaultRequestWait) |
| 1405 | } |
| 1406 | l := &streamLister{js: js} |
| 1407 | l.js.opts.streamListSubject = fmt.Sprintf(objAllChunksPreTmpl, "*") |
| 1408 | l.js.opts.ctx = o.ctx |
| 1409 | go func() { |
| 1410 | if cancel != nil { |
| 1411 | defer cancel() |
| 1412 | } |
| 1413 | defer close(ch) |
| 1414 | for l.Next() { |
| 1415 | for _, info := range l.Page() { |
| 1416 | if !strings.HasPrefix(info.Config.Name, "OBJ_") { |
| 1417 | continue |
| 1418 | } |
| 1419 | select { |
| 1420 | case ch <- &ObjectBucketStatus{ |
| 1421 | nfo: info, |
| 1422 | bucket: strings.TrimPrefix(info.Config.Name, "OBJ_"), |
| 1423 | }: |
| 1424 | case <-o.ctx.Done(): |
| 1425 | return |
| 1426 | } |
| 1427 | } |
| 1428 | } |
| 1429 | }() |
| 1430 | |
| 1431 | return ch |
| 1432 | } |
nothing calls this directly
no test coverage detected