MCPcopy
hub / github.com/nats-io/nats.go / ObjectStores

Method ObjectStores

object.go:1392–1432  ·  view source on GitHub ↗

ObjectStores is used to retrieve a list of bucket statuses

(opts ...ObjectOpt)

Source from the content-addressed store, hash-verified

1390
1391// ObjectStores is used to retrieve a list of bucket statuses
1392func (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}

Callers

nothing calls this directly

Calls 4

NextMethod · 0.95
PageMethod · 0.95
configureObjectMethod · 0.65
DoneMethod · 0.65

Tested by

no test coverage detected