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

Method CreateOrUpdateStream

jetstream/jetstream.go:786–796  ·  view source on GitHub ↗

CreateOrUpdateStream creates a stream with the given config. If stream already exists, it will be updated (if possible).

(ctx context.Context, cfg StreamConfig)

Source from the content-addressed store, hash-verified

784// CreateOrUpdateStream creates a stream with the given config. If stream
785// already exists, it will be updated (if possible).
786func (js *jetStream) CreateOrUpdateStream(ctx context.Context, cfg StreamConfig) (Stream, error) {
787 s, err := js.UpdateStream(ctx, cfg)
788 if err != nil {
789 if !errors.Is(err, ErrStreamNotFound) {
790 return nil, err
791 }
792 return js.CreateStream(ctx, cfg)
793 }
794
795 return s, nil
796}
797
798// Stream fetches [StreamInfo] and returns a [Stream] interface for a given stream name.
799// If stream does not exist, ErrStreamNotFound is returned.

Callers 2

Calls 3

UpdateStreamMethod · 0.95
CreateStreamMethod · 0.95
IsMethod · 0.45

Tested by

no test coverage detected