ReadRing represents the read interface to the ring.
| 38 | |
| 39 | // ReadRing represents the read interface to the ring. |
| 40 | type ReadRing interface { |
| 41 | |
| 42 | // Get returns n (or more) instances which form the replicas for the given key. |
| 43 | // bufDescs, bufHosts and bufZones are slices to be overwritten for the return value |
| 44 | // to avoid memory allocation; can be nil, or created with ring.MakeBuffersForGet(). |
| 45 | Get(key uint32, op Operation, bufDescs []InstanceDesc, bufHosts []string, bufZones map[string]int) (ReplicationSet, error) |
| 46 | |
| 47 | // GetAllHealthy returns all healthy instances in the ring, for the given operation. |
| 48 | // This function doesn't check if the quorum is honored, so doesn't fail if the number |
| 49 | // of unhealthy instances is greater than the tolerated max unavailable. |
| 50 | GetAllHealthy(op Operation) (ReplicationSet, error) |
| 51 | |
| 52 | // GetAllInstanceDescs returns a slice of healthy and unhealthy InstanceDesc. |
| 53 | GetAllInstanceDescs(op Operation) ([]InstanceDesc, []InstanceDesc, error) |
| 54 | |
| 55 | // GetInstanceDescsForOperation returns map of InstanceDesc with instance ID as the keys. |
| 56 | GetInstanceDescsForOperation(op Operation) (map[string]InstanceDesc, error) |
| 57 | |
| 58 | // GetReplicationSetForOperation returns all instances where the input operation should be executed. |
| 59 | // The resulting ReplicationSet doesn't necessarily contains all healthy instances |
| 60 | // in the ring, but could contain the minimum set of instances required to execute |
| 61 | // the input operation. |
| 62 | GetReplicationSetForOperation(op Operation) (ReplicationSet, error) |
| 63 | |
| 64 | ReplicationFactor() int |
| 65 | |
| 66 | // InstancesCount returns the number of instances in the ring. |
| 67 | InstancesCount() int |
| 68 | |
| 69 | // ShuffleShard returns a subring for the provided identifier (eg. a tenant ID) |
| 70 | // and size (number of instances). |
| 71 | ShuffleShard(identifier string, size int) ReadRing |
| 72 | |
| 73 | // ShuffleShardWithZoneStability does the same as ShuffleShard but using a different shuffle sharding algorithm. |
| 74 | // It doesn't round up shard size to be divisible to number of zones and make sure when scaling up/down one |
| 75 | // shard size at a time, at most 1 instance can be changed. |
| 76 | // It is only used in Store Gateway for now. |
| 77 | ShuffleShardWithZoneStability(identifier string, size int) ReadRing |
| 78 | |
| 79 | // GetInstanceState returns the current state of an instance or an error if the |
| 80 | // instance does not exist in the ring. |
| 81 | GetInstanceState(instanceID string) (InstanceState, error) |
| 82 | |
| 83 | // GetInstanceIdByAddr returns the instance id from its address or an error if the |
| 84 | // // instance does not exist in the ring. |
| 85 | GetInstanceIdByAddr(addr string) (string, error) |
| 86 | |
| 87 | // ShuffleShardWithLookback is like ShuffleShard() but the returned subring includes |
| 88 | // all instances that have been part of the identifier's shard since "now - lookbackPeriod". |
| 89 | ShuffleShardWithLookback(identifier string, size int, lookbackPeriod time.Duration, now time.Time) ReadRing |
| 90 | |
| 91 | // HasInstance returns whether the ring contains an instance matching the provided instanceID. |
| 92 | HasInstance(instanceID string) bool |
| 93 | |
| 94 | // CleanupShuffleShardCache should delete cached shuffle-shard subrings for given identifier. |
| 95 | CleanupShuffleShardCache(identifier string) |
| 96 | } |
| 97 |