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

Method DeleteConsumer

jsm.go:599–631  ·  view source on GitHub ↗

DeleteConsumer deletes a Consumer.

(stream, consumer string, opts ...JSOpt)

Source from the content-addressed store, hash-verified

597
598// DeleteConsumer deletes a Consumer.
599func (js *js) DeleteConsumer(stream, consumer string, opts ...JSOpt) error {
600 if err := checkStreamName(stream); err != nil {
601 return err
602 }
603 if err := checkConsumerName(consumer); err != nil {
604 return err
605 }
606 o, cancel, err := getJSContextOpts(js.opts, opts...)
607 if err != nil {
608 return err
609 }
610 if cancel != nil {
611 defer cancel()
612 }
613
614 dcSubj := js.apiSubj(fmt.Sprintf(apiConsumerDeleteT, stream, consumer))
615 r, err := js.apiRequestWithContext(o.ctx, dcSubj, nil)
616 if err != nil {
617 return err
618 }
619 var resp consumerDeleteResponse
620 if err := json.Unmarshal(r.Data, &resp); err != nil {
621 return err
622 }
623
624 if resp.Error != nil {
625 if errors.Is(resp.Error, ErrConsumerNotFound) {
626 return ErrConsumerNotFound
627 }
628 return resp.Error
629 }
630 return nil
631}
632
633// ConsumerInfo returns information about a Consumer.
634func (js *js) ConsumerInfo(stream, consumer string, opts ...JSOpt) (*ConsumerInfo, error) {

Callers

nothing calls this directly

Calls 6

apiSubjMethod · 0.95
apiRequestWithContextMethod · 0.95
checkStreamNameFunction · 0.85
checkConsumerNameFunction · 0.85
getJSContextOptsFunction · 0.85
IsMethod · 0.45

Tested by

no test coverage detected