MCPcopy
hub / github.com/grafana/dskit / Get

Method Get

ring/partition_ring.go:555–583  ·  view source on GitHub ↗

Get implements DoBatchRing.Get.

(key uint32, _ Operation, bufInstances []InstanceDesc, _, _ []string)

Source from the content-addressed store, hash-verified

553
554// Get implements DoBatchRing.Get.
555func (r *ActivePartitionBatchRing) Get(key uint32, _ Operation, bufInstances []InstanceDesc, _, _ []string) (ReplicationSet, error) {
556 partitionID, err := r.ring.ActivePartitionForKey(key)
557 if err != nil {
558 return ReplicationSet{}, err
559 }
560
561 // Ensure we have enough capacity in bufInstances.
562 if cap(bufInstances) < 1 {
563 bufInstances = []InstanceDesc{{}}
564 } else {
565 bufInstances = bufInstances[:1]
566 }
567
568 partitionIDString := strconv.Itoa(int(partitionID))
569
570 bufInstances[0] = InstanceDesc{
571 Addr: partitionIDString,
572 Timestamp: 0,
573 State: ACTIVE,
574 Id: partitionIDString,
575 }
576
577 return ReplicationSet{
578 Instances: bufInstances,
579 MaxErrors: 0,
580 MaxUnavailableZones: 0,
581 ZoneAwarenessEnabled: false,
582 }, nil
583}
584
585// PartitionKeys holds a partition ID and the indexes of keys assigned to it.
586type PartitionKeys struct {

Callers 1

Calls 1

ActivePartitionForKeyMethod · 0.80

Tested by 1