MCPcopy
hub / github.com/segmentio/kafka-go / loadCachedPartitions

Function loadCachedPartitions

writer.go:1293–1309  ·  view source on GitHub ↗
(numPartitions int)

Source from the content-addressed store, hash-verified

1291var partitionsCache atomic.Value
1292
1293func loadCachedPartitions(numPartitions int) []int {
1294 partitions, ok := partitionsCache.Load().([]int)
1295 if ok && len(partitions) >= numPartitions {
1296 return partitions[:numPartitions]
1297 }
1298
1299 const alignment = 128
1300 n := ((numPartitions / alignment) + 1) * alignment
1301
1302 partitions = make([]int, n)
1303 for i := range partitions {
1304 partitions[i] = i
1305 }
1306
1307 partitionsCache.Store(partitions)
1308 return partitions[:numPartitions]
1309}

Callers 1

WriteMessagesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected