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

Function fetchConsumerInfo

jetstream/consumer.go:410–436  ·  view source on GitHub ↗
(ctx context.Context, js *jetStream, stream, name string)

Source from the content-addressed store, hash-verified

408}
409
410func fetchConsumerInfo(ctx context.Context, js *jetStream, stream, name string) (*ConsumerInfo, error) {
411 ctx, cancel := js.wrapContextWithoutDeadline(ctx)
412 if cancel != nil {
413 defer cancel()
414 }
415 if err := validateConsumerName(name); err != nil {
416 return nil, err
417 }
418 infoSubject := fmt.Sprintf(apiConsumerInfoT, stream, name)
419
420 var resp consumerInfoResponse
421
422 if _, err := js.apiRequestJSON(ctx, infoSubject, &resp); err != nil {
423 return nil, err
424 }
425 if resp.Error != nil {
426 if resp.Error.ErrorCode == JSErrCodeConsumerNotFound {
427 return nil, ErrConsumerNotFound
428 }
429 return nil, resp.Error
430 }
431 if resp.Error == nil && resp.ConsumerInfo == nil {
432 return nil, ErrConsumerNotFound
433 }
434
435 return resp.ConsumerInfo, nil
436}
437
438func deleteConsumer(ctx context.Context, js *jetStream, stream, consumer string) error {
439 ctx, cancel := js.wrapContextWithoutDeadline(ctx)

Callers 2

getConsumerFunction · 0.85
getPushConsumerFunction · 0.85

Calls 3

validateConsumerNameFunction · 0.85
apiRequestJSONMethod · 0.80

Tested by

no test coverage detected