Documentation
¶
Overview ¶
Package indextest provides a test double for index.Index.
Index ¶
- type Index
- func (f *Index) BaseURL(shardName string) (string, bool)
- func (f *Index) ClusterContext(parent context.Context, cluster logicalcluster.Name) (context.Context, context.CancelFunc)
- func (f *Index) Lookup(path logicalcluster.Path) (index.Result, bool)
- func (f *Index) LookupURL(path logicalcluster.Path) (index.Result, bool)
- func (f *Index) RecentlyMigrated(cluster logicalcluster.Name) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// Clusters maps a logical cluster to the name of the shard hosting it.
Clusters map[logicalcluster.Name]string
// Shards maps a shard name to its base URL.
Shards map[string]string
// RecentlyMigratedClusters are the clusters RecentlyMigrated reports.
RecentlyMigratedClusters map[logicalcluster.Name]bool
// Registered and Released count the ClusterContext calls and the
// calls of the cancel functions they returned.
Registered atomic.Int32
Released atomic.Int32
}
Index is a map-based index.Index: it maps logical clusters to shards and shards to base URLs. Lookups resolve logical cluster names only, not workspace paths. The maps must not be changed once the Index is in use.
func (*Index) ClusterContext ¶
func (f *Index) ClusterContext(parent context.Context, cluster logicalcluster.Name) (context.Context, context.CancelFunc)
ClusterContext returns a cancellable child of parent and counts the registration and its release.
func (*Index) Lookup ¶
Lookup returns the shard hosting the cluster, with the cluster's URL on that shard.
func (*Index) RecentlyMigrated ¶
func (f *Index) RecentlyMigrated(cluster logicalcluster.Name) bool
RecentlyMigrated reports whether the cluster is in RecentlyMigratedClusters.