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

Method List

object.go:1168–1208  ·  view source on GitHub ↗

List will list all the objects in this store.

(opts ...ListObjectsOpt)

Source from the content-addressed store, hash-verified

1166
1167// List will list all the objects in this store.
1168func (obs *obs) List(opts ...ListObjectsOpt) ([]*ObjectInfo, error) {
1169 var o listObjectOpts
1170 for _, opt := range opts {
1171 if opt != nil {
1172 if err := opt.configureListObjects(&o); err != nil {
1173 return nil, err
1174 }
1175 }
1176 }
1177 watchOpts := make([]WatchOpt, 0)
1178 if !o.showDeleted {
1179 watchOpts = append(watchOpts, IgnoreDeletes())
1180 }
1181 watcher, err := obs.Watch(watchOpts...)
1182 if err != nil {
1183 return nil, err
1184 }
1185 defer watcher.Stop()
1186 if o.ctx == nil {
1187 o.ctx = context.Background()
1188 }
1189
1190 var objs []*ObjectInfo
1191 updates := watcher.Updates()
1192Updates:
1193 for {
1194 select {
1195 case entry := <-updates:
1196 if entry == nil {
1197 break Updates
1198 }
1199 objs = append(objs, entry)
1200 case <-o.ctx.Done():
1201 return nil, o.ctx.Err()
1202 }
1203 }
1204 if len(objs) == 0 {
1205 return nil, ErrNoObjectsFound
1206 }
1207 return objs, nil
1208}
1209
1210// ObjectBucketStatus represents status of a Bucket, implements ObjectStoreStatus
1211type ObjectBucketStatus struct {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected