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

Method Put

jetstream/kv.go:1030–1051  ·  view source on GitHub ↗

Put will place the new value for the key into the store.

(ctx context.Context, key string, value []byte)

Source from the content-addressed store, hash-verified

1028
1029// Put will place the new value for the key into the store.
1030func (kv *kvs) Put(ctx context.Context, key string, value []byte) (uint64, error) {
1031 if !keyValid(key) {
1032 return 0, ErrInvalidKey
1033 }
1034
1035 var b strings.Builder
1036 if kv.useJSPfx {
1037 b.WriteString(kv.js.opts.apiPrefix)
1038 }
1039 if kv.putPre != "" {
1040 b.WriteString(kv.putPre)
1041 } else {
1042 b.WriteString(kv.pre)
1043 }
1044 b.WriteString(key)
1045
1046 pa, err := kv.js.Publish(ctx, b.String(), value)
1047 if err != nil {
1048 return 0, err
1049 }
1050 return pa.Sequence, err
1051}
1052
1053// PutString will place the string for the key into the store.
1054func (kv *kvs) PutString(ctx context.Context, key string, value string) (uint64, error) {

Callers 1

PutStringMethod · 0.95

Calls 3

keyValidFunction · 0.70
PublishMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected