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

Method UpdateKeyValue

jetstream/kv.go:572–591  ·  view source on GitHub ↗
(ctx context.Context, cfg KeyValueConfig)

Source from the content-addressed store, hash-verified

570}
571
572func (js *jetStream) UpdateKeyValue(ctx context.Context, cfg KeyValueConfig) (KeyValue, error) {
573 scfg, err := js.prepareKeyValueConfig(ctx, cfg)
574 if err != nil {
575 return nil, err
576 }
577
578 stream, err := js.UpdateStream(ctx, scfg)
579 if err != nil {
580 if errors.Is(err, ErrStreamNotFound) {
581 err = fmt.Errorf("%w: %s", ErrBucketNotFound, cfg.Bucket)
582 }
583 return nil, err
584 }
585 pushJS, err := js.legacyJetStream()
586 if err != nil {
587 return nil, err
588 }
589
590 return mapStreamToKVS(js, pushJS, stream), nil
591}
592
593func (js *jetStream) CreateOrUpdateKeyValue(ctx context.Context, cfg KeyValueConfig) (KeyValue, error) {
594 scfg, err := js.prepareKeyValueConfig(ctx, cfg)

Callers

nothing calls this directly

Calls 6

prepareKeyValueConfigMethod · 0.95
UpdateStreamMethod · 0.95
legacyJetStreamMethod · 0.95
ErrorfMethod · 0.80
mapStreamToKVSFunction · 0.70
IsMethod · 0.45

Tested by

no test coverage detected