Documentation ¶
Index ¶
- Constants
- Variables
- func AddControllerFlags(fs *pflag.FlagSet)
- func AddFlags(fs *pflag.FlagSet)
- func AddSchedulerFlags(fs *pflag.FlagSet)
- func BuildCache(scheme *runtime.Scheme, shardingObjects ...client.Object) cache.NewCacheFunc
- func BuildCacheWithOptions(opts cache.Options, shardingObjects ...client.Object) cache.NewCacheFunc
- func DelScheduledShardID(o client.Object)
- func GetScheduledShardID(o client.Object) (string, bool)
- func GetShardIDSuffix() string
- func IsMaster() bool
- func PropagateScheduledShardIDLabel(from client.Object, to client.Object)
- func SetScheduledShardID(o client.Object, id string)
- type Scheduler
Constants ¶
const ( // LabelKubeVelaShardID label key for identify the shard id for the controller LabelKubeVelaShardID = "controller.core.oam.dev/shard-id" // LabelKubeVelaScheduledShardID label key for identify the scheduled shard id for the resource LabelKubeVelaScheduledShardID = "controller.core.oam.dev/scheduled-shard-id" // MasterShardID the master shard id MasterShardID = "master" )
Variables ¶
var ( // ShardID the id of the shard ShardID = MasterShardID // EnableSharding whether enable sharding EnableSharding bool // SchedulableShards the shards for schedule SchedulableShards []string // DynamicDiscoverySchedulerResyncPeriod resync period for default dynamic discovery scheduler DynamicDiscoverySchedulerResyncPeriod = 5 * time.Minute )
var DefaultScheduler = singleton.NewSingleton[Scheduler](func() Scheduler { SchedulableShards = velaslices.Filter(SchedulableShards, func(s string) bool { return len(s) > 0 }) if len(SchedulableShards) > 0 { klog.Infof("staticScheduler initialized") return NewStaticScheduler(SchedulableShards) } klog.Infof("dynamicDiscoveryScheduler initialized") return NewDynamicDiscoveryScheduler(meta.Name, DynamicDiscoverySchedulerResyncPeriod) })
DefaultScheduler default scheduler
Functions ¶
func AddControllerFlags ¶
AddControllerFlags add sharding controller flags
func AddSchedulerFlags ¶
AddSchedulerFlags add sharding scheduler flags
func BuildCache ¶
BuildCache add shard-id label selector for given typed object
func BuildCacheWithOptions ¶
BuildCacheWithOptions add shard-id label selector to sharding objects with options
func DelScheduledShardID ¶
DelScheduledShardID delete shard-id from target object
func GetScheduledShardID ¶
GetScheduledShardID return the scheduled shard-id of the object and if it is scheduled
func GetShardIDSuffix ¶
func GetShardIDSuffix() string
GetShardIDSuffix return suffix for shard id if enabled
func PropagateScheduledShardIDLabel ¶
PropagateScheduledShardIDLabel copy the shard-id from source obj to target obj, remove if not exist
func SetScheduledShardID ¶
SetScheduledShardID set shard-id to target object
Types ¶
type Scheduler ¶
Scheduler schedule shard-id for object
func NewDynamicDiscoveryScheduler ¶
NewDynamicDiscoveryScheduler create a scheduler that allow dynamic discovery for available shards
func NewStaticScheduler ¶
NewStaticScheduler create a scheduler that do not make update but only use predefined shards for allocate