KeyValueStores is used to retrieve a list of key value store statuses
(ctx context.Context)
| 775 | |
| 776 | // KeyValueStores is used to retrieve a list of key value store statuses |
| 777 | func (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 |
| 808 | type KeyValueBucketStatus struct { |
nothing calls this directly
no test coverage detected