sharding

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package sharding provides consistent hashing for distributing repositories across shards.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractOrdinal

func ExtractOrdinal(podName string) int

ExtractOrdinal extracts the ordinal index from a StatefulSet pod name.

func GetShardForRepo

func GetShardForRepo(repoName string, totalShards int) int

GetShardForRepo returns the shard index for a repository name using FNV-1a consistent hashing. This must be identical across all consumers (indexer, queue, federation, search) to ensure the same repo always maps to the same shard.

Types

type Config

type Config struct {
	ShardIndex  int
	TotalShards int
	Enabled     bool
}

Config holds sharding configuration read from environment.

func GetConfig

func GetConfig() Config

GetConfig reads sharding configuration from environment variables.

func (Config) ShouldHandleRepo

func (c Config) ShouldHandleRepo(repoName string) bool

ShouldHandleRepo returns true if the given shard should handle the repo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL