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

Function mapStreamToKVS

jetstream/kv.go:1564–1593  ·  view source on GitHub ↗
(js *jetStream, pushJS nats.JetStreamContext, stream Stream)

Source from the content-addressed store, hash-verified

1562}
1563
1564func mapStreamToKVS(js *jetStream, pushJS nats.JetStreamContext, stream Stream) *kvs {
1565 info := stream.CachedInfo()
1566 bucket := strings.TrimPrefix(info.Config.Name, kvBucketNamePre)
1567 kv := &kvs{
1568 name: bucket,
1569 streamName: info.Config.Name,
1570 pre: fmt.Sprintf(kvSubjectsPreTmpl, bucket),
1571 js: js,
1572 pushJS: pushJS,
1573 stream: stream,
1574 // Determine if we need to use the JS prefix in front of Put and Delete operations
1575 useJSPfx: js.opts.apiPrefix != DefaultAPIPrefix,
1576 useDirect: info.Config.AllowDirect,
1577 }
1578
1579 // If we are mirroring, we will have mirror direct on, so just use the mirror name
1580 // and override use
1581 if m := info.Config.Mirror; m != nil {
1582 bucket := strings.TrimPrefix(m.Name, kvBucketNamePre)
1583 if m.External != nil && m.External.APIPrefix != "" {
1584 kv.useJSPfx = false
1585 kv.pre = fmt.Sprintf(kvSubjectsPreTmpl, bucket)
1586 kv.putPre = fmt.Sprintf(kvSubjectsPreDomainTmpl, m.External.APIPrefix, bucket)
1587 } else {
1588 kv.putPre = fmt.Sprintf(kvSubjectsPreTmpl, bucket)
1589 }
1590 }
1591
1592 return kv
1593}

Callers 4

KeyValueMethod · 0.70
CreateKeyValueMethod · 0.70
UpdateKeyValueMethod · 0.70

Calls 1

CachedInfoMethod · 0.65

Tested by

no test coverage detected