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

Function mapStreamToKVS

kv.go:1288–1315  ·  view source on GitHub ↗
(js *js, info *StreamInfo)

Source from the content-addressed store, hash-verified

1286}
1287
1288func mapStreamToKVS(js *js, info *StreamInfo) *kvs {
1289 bucket := strings.TrimPrefix(info.Config.Name, kvBucketNamePre)
1290
1291 kv := &kvs{
1292 name: bucket,
1293 stream: info.Config.Name,
1294 pre: fmt.Sprintf(kvSubjectsPreTmpl, bucket),
1295 js: js,
1296 // Determine if we need to use the JS prefix in front of Put and Delete operations
1297 useJSPfx: js.opts.pre != defaultAPIPrefix,
1298 useDirect: info.Config.AllowDirect,
1299 }
1300
1301 // If we are mirroring, we will have mirror direct on, so just use the mirror name
1302 // and override use
1303 if m := info.Config.Mirror; m != nil {
1304 bucket := strings.TrimPrefix(m.Name, kvBucketNamePre)
1305 if m.External != nil && m.External.APIPrefix != _EMPTY_ {
1306 kv.useJSPfx = false
1307 kv.pre = fmt.Sprintf(kvSubjectsPreTmpl, bucket)
1308 kv.putPre = fmt.Sprintf(kvSubjectsPreDomainTmpl, m.External.APIPrefix, bucket)
1309 } else {
1310 kv.putPre = fmt.Sprintf(kvSubjectsPreTmpl, bucket)
1311 }
1312 }
1313
1314 return kv
1315}

Callers 2

KeyValueMethod · 0.70
CreateKeyValueMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected