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

Method CreateOrUpdateKeyValue

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

Source from the content-addressed store, hash-verified

591}
592
593func (js *jetStream) CreateOrUpdateKeyValue(ctx context.Context, cfg KeyValueConfig) (KeyValue, error) {
594 scfg, err := js.prepareKeyValueConfig(ctx, cfg)
595 if err != nil {
596 return nil, err
597 }
598
599 stream, err := js.CreateOrUpdateStream(ctx, scfg)
600 if err != nil {
601 return nil, err
602 }
603 pushJS, err := js.legacyJetStream()
604 if err != nil {
605 return nil, err
606 }
607
608 return mapStreamToKVS(js, pushJS, stream), nil
609}
610
611func (js *jetStream) prepareKeyValueConfig(ctx context.Context, cfg KeyValueConfig) (StreamConfig, error) {
612 if !bucketValid(cfg.Bucket) {

Callers

nothing calls this directly

Calls 4

prepareKeyValueConfigMethod · 0.95
CreateOrUpdateStreamMethod · 0.95
legacyJetStreamMethod · 0.95
mapStreamToKVSFunction · 0.70

Tested by

no test coverage detected