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

Method Info

jetstream/consumer.go:221–244  ·  view source on GitHub ↗

Info fetches current ConsumerInfo from the server.

(ctx context.Context)

Source from the content-addressed store, hash-verified

219
220// Info fetches current ConsumerInfo from the server.
221func (p *pushConsumer) Info(ctx context.Context) (*ConsumerInfo, error) {
222 ctx, cancel := p.js.wrapContextWithoutDeadline(ctx)
223 if cancel != nil {
224 defer cancel()
225 }
226 infoSubject := fmt.Sprintf(apiConsumerInfoT, p.stream, p.name)
227 var resp consumerInfoResponse
228
229 if _, err := p.js.apiRequestJSON(ctx, infoSubject, &resp); err != nil {
230 return nil, err
231 }
232 if resp.Error != nil {
233 if resp.Error.ErrorCode == JSErrCodeConsumerNotFound {
234 return nil, ErrConsumerNotFound
235 }
236 return nil, resp.Error
237 }
238 if resp.Error == nil && resp.ConsumerInfo == nil {
239 return nil, ErrConsumerNotFound
240 }
241
242 p.info = resp.ConsumerInfo
243 return resp.ConsumerInfo, nil
244}
245
246// CachedInfo returns ConsumerInfo currently cached on this consumer.
247// 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