(ctx context.Context, key string, value []byte, revision uint64, ttl time.Duration)
| 1091 | } |
| 1092 | |
| 1093 | func (kv *kvs) updateRevision(ctx context.Context, key string, value []byte, revision uint64, ttl time.Duration) (uint64, error) { |
| 1094 | if !keyValid(key) { |
| 1095 | return 0, ErrInvalidKey |
| 1096 | } |
| 1097 | |
| 1098 | var b strings.Builder |
| 1099 | if kv.useJSPfx { |
| 1100 | b.WriteString(kv.js.opts.apiPrefix) |
| 1101 | } |
| 1102 | if kv.putPre != "" { |
| 1103 | b.WriteString(kv.putPre) |
| 1104 | } else { |
| 1105 | b.WriteString(kv.pre) |
| 1106 | } |
| 1107 | b.WriteString(key) |
| 1108 | |
| 1109 | m := nats.Msg{Subject: b.String(), Header: nats.Header{}, Data: value} |
| 1110 | opts := []PublishOpt{ |
| 1111 | WithExpectLastSequencePerSubject(revision), |
| 1112 | } |
| 1113 | if ttl > 0 { |
| 1114 | opts = append(opts, WithMsgTTL(ttl)) |
| 1115 | } |
| 1116 | |
| 1117 | pa, err := kv.js.PublishMsg(ctx, &m, opts...) |
| 1118 | if err != nil { |
| 1119 | return 0, err |
| 1120 | } |
| 1121 | return pa.Sequence, err |
| 1122 | } |
| 1123 | |
| 1124 | // Delete will place a delete marker and leave all revisions. |
| 1125 | func (kv *kvs) Delete(ctx context.Context, key string, opts ...KVDeleteOpt) error { |
no test coverage detected