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

Method DeleteStream

jetstream/jetstream.go:829–850  ·  view source on GitHub ↗

DeleteStream removes a stream with given name

(ctx context.Context, name string)

Source from the content-addressed store, hash-verified

827
828// DeleteStream removes a stream with given name
829func (js *jetStream) DeleteStream(ctx context.Context, name string) error {
830 if err := validateStreamName(name); err != nil {
831 return err
832 }
833 ctx, cancel := js.wrapContextWithoutDeadline(ctx)
834 if cancel != nil {
835 defer cancel()
836 }
837 deleteSubject := fmt.Sprintf(apiStreamDeleteT, name)
838 var resp streamDeleteResponse
839
840 if _, err := js.apiRequestJSON(ctx, deleteSubject, &resp); err != nil {
841 return err
842 }
843 if resp.Error != nil {
844 if resp.Error.ErrorCode == JSErrCodeStreamNotFound {
845 return ErrStreamNotFound
846 }
847 return resp.Error
848 }
849 return nil
850}
851
852// CreateOrUpdateConsumer creates a consumer on a given stream with
853// the given config. If consumer already exists, it will be updated (if

Callers 2

DeleteKeyValueMethod · 0.95
DeleteObjectStoreMethod · 0.95

Calls 3

apiRequestJSONMethod · 0.95
validateStreamNameFunction · 0.85

Tested by

no test coverage detected