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

Method List

jetstream/object.go:1352–1389  ·  view source on GitHub ↗

List will list all the objects in this store.

(ctx context.Context, opts ...ListObjectsOpt)

Source from the content-addressed store, hash-verified

1350
1351// List will list all the objects in this store.
1352func (obs *obs) List(ctx context.Context, opts ...ListObjectsOpt) ([]*ObjectInfo, error) {
1353 var o listObjectOpts
1354 for _, opt := range opts {
1355 if opt != nil {
1356 if err := opt(&o); err != nil {
1357 return nil, err
1358 }
1359 }
1360 }
1361 watchOpts := make([]WatchOpt, 0)
1362 if !o.showDeleted {
1363 watchOpts = append(watchOpts, IgnoreDeletes())
1364 }
1365 watcher, err := obs.Watch(ctx, watchOpts...)
1366 if err != nil {
1367 return nil, err
1368 }
1369 defer watcher.Stop()
1370
1371 var objs []*ObjectInfo
1372 updates := watcher.Updates()
1373Updates:
1374 for {
1375 select {
1376 case entry := <-updates:
1377 if entry == nil {
1378 break Updates
1379 }
1380 objs = append(objs, entry)
1381 case <-ctx.Done():
1382 return nil, ctx.Err()
1383 }
1384 }
1385 if len(objs) == 0 {
1386 return nil, ErrNoObjectsFound
1387 }
1388 return objs, nil
1389}
1390
1391// ObjectBucketStatus represents status of a Bucket, implements ObjectStoreStatus
1392type ObjectBucketStatus struct {

Callers

nothing calls this directly

Calls 6

WatchMethod · 0.95
IgnoreDeletesFunction · 0.70
StopMethod · 0.65
UpdatesMethod · 0.65
DoneMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected