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

Method Info

jetstream/consumer.go:188–211  ·  view source on GitHub ↗

Info fetches current ConsumerInfo from the server.

(ctx context.Context)

Source from the content-addressed store, hash-verified

186
187// Info fetches current ConsumerInfo from the server.
188func (p *pullConsumer) Info(ctx context.Context) (*ConsumerInfo, error) {
189 ctx, cancel := p.js.wrapContextWithoutDeadline(ctx)
190 if cancel != nil {
191 defer cancel()
192 }
193 infoSubject := fmt.Sprintf(apiConsumerInfoT, p.stream, p.name)
194 var resp consumerInfoResponse
195
196 if _, err := p.js.apiRequestJSON(ctx, infoSubject, &resp); err != nil {
197 return nil, err
198 }
199 if resp.Error != nil {
200 if resp.Error.ErrorCode == JSErrCodeConsumerNotFound {
201 return nil, ErrConsumerNotFound
202 }
203 return nil, resp.Error
204 }
205 if resp.Error == nil && resp.ConsumerInfo == nil {
206 return nil, ErrConsumerNotFound
207 }
208
209 p.info = resp.ConsumerInfo
210 return resp.ConsumerInfo, nil
211}
212
213// CachedInfo returns ConsumerInfo currently cached on this consumer.
214// This method does not perform any network requests. The cached

Callers

nothing calls this directly

Calls 2

apiRequestJSONMethod · 0.80

Tested by

no test coverage detected