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

Method KeyValueStores

jetstream/kv.go:777–805  ·  view source on GitHub ↗

KeyValueStores is used to retrieve a list of key value store statuses

(ctx context.Context)

Source from the content-addressed store, hash-verified

775
776// KeyValueStores is used to retrieve a list of key value store statuses
777func (js *jetStream) KeyValueStores(ctx context.Context) KeyValueLister {
778 res := &kvLister{
779 kvs: make(chan KeyValueStatus),
780 }
781 l := &streamLister{js: js}
782 streamsReq := streamsRequest{
783 Subject: fmt.Sprintf(kvSubjectsTmpl, "*"),
784 }
785 go func() {
786 defer close(res.kvs)
787 for {
788 page, err := l.streamInfos(ctx, streamsReq)
789 if err != nil && !errors.Is(err, ErrEndOfData) {
790 res.err = err
791 return
792 }
793 for _, info := range page {
794 if !strings.HasPrefix(info.Config.Name, kvBucketNamePre) {
795 continue
796 }
797 res.kvs <- &KeyValueBucketStatus{info: info, bucket: strings.TrimPrefix(info.Config.Name, kvBucketNamePre)}
798 }
799 if errors.Is(err, ErrEndOfData) {
800 return
801 }
802 }
803 }()
804 return res
805}
806
807// KeyValueBucketStatus represents status of a Bucket, implements KeyValueStatus
808type KeyValueBucketStatus struct {

Callers

nothing calls this directly

Calls 2

streamInfosMethod · 0.95
IsMethod · 0.45

Tested by

no test coverage detected