Documentation ¶
Index ¶
Constants ¶
View Source
const ( ScalingThresholdDuration1Minute = 1 ScalingThresholdDuration5Minute = 5 ScalingThresholdDuration15Minute = 15 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoScaler ¶
type AutoScaler struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *Config) (*AutoScaler, error)
func (*AutoScaler) CalcScalingOperation ¶
func (a *AutoScaler) CalcScalingOperation(ctx context.Context) (*ScalingOperation, error)
func (*AutoScaler) Run ¶
func (a *AutoScaler) Run(ctx context.Context) (*ScalingOperation, error)
Run executes scale in/out if needed based on the configuration This method will return non-nil ScalingOperation with error when error happens after scaling operation is decided
type AutoScalingConfig ¶
type AutoScalingConfig struct { MetricsProvider metrics.Provider `validate:"required"` DesiredCPUUtilPercent int `validate:"required,gt=0,lt=100"` ScaleOutThresholdDuration time.Duration `validate:"gte=0"` ScaleOutCoolDownDuration time.Duration `validate:"gte=0"` ScaleInThresholdDuration time.Duration `validate:"gte=0"` ScaleInCoolDownDuration time.Duration `validate:"gte=0"` }
type Config ¶
type Config struct { ElasticCloudClient *api.API `validate:"required"` DeploymentID string `validate:"required"` ElasticsearchClient *elasticsearch.TypedClient `validate:"required"` Scaling ScalingConfig `validate:"required"` // DryRun disables applying actual scaling operation DryRun bool }
type ScalingConfig ¶
type ScalingConfig struct { // Default memory min size. It can be overwritten by ScheduledScalingConfig.MinSizeMemoryGB. // Available number is only 64,...(64xN node) // If you have multiple zone, this memory is per zone. // NOTE: Currently we only support 64GB node for simplicity DefaultMinSizeMemoryGB int `validate:"gte=64"` // Default memory max size. It can be overwritten by ScheduledScalingConfig.MaxSizeMemoryGB. // Available number is only 64,...(64xN node) // If you have multiple zone, this memory is per zone. // NOTE: Currently we only support 64GB node for simplicity DefaultMaxSizeMemoryGB int `validate:"gte=64,gtefield=DefaultMinSizeMemoryGB"` AutoScaling *AutoScalingConfig // If the time is within multiple schedules, the last schedule will be applied // e.g. [{min: 1, max: 2}, {min:2, max:4}] => min: 2, max: 4 ScheduledScalings []*ScheduledScalingConfig // Index to update replicas when scaling out/in Index string `validate:"required"` ShardsPerNode int `validate:"required,gte=1"` }
type ScalingDirection ¶
type ScalingDirection string
const ( ScalingDirectionOut ScalingDirection = "SCALING_OUT" ScalingDirectionIn ScalingDirection = "SCALING_IN" ScalingDirectionNone ScalingDirection = "NOT_SCALING" )
type ScalingOperation ¶
type ScalingOperation struct { FromTopologySize *models.TopologySize ToTopologySize *models.TopologySize FromReplicaNum int ToReplicaNum int Reason string }
func (*ScalingOperation) Direction ¶
func (s *ScalingOperation) Direction() ScalingDirection
func (*ScalingOperation) NeedTopologySizeUpdate ¶
func (s *ScalingOperation) NeedTopologySizeUpdate() bool
type ScalingThresholdDurationMinute ¶
type ScalingThresholdDurationMinute int
type ScheduledScalingConfig ¶
type ScheduledScalingConfig struct { // MinSizeMemoryGB is the minimum memory size during the specified period // If 0, then `ScalingConfig.DefaultMinSizeMemoryGB` will be used // NOTE: Currently we only support 64GB node for simplicity MinSizeMemoryGB int `validate:"gte=64"` // MaxSizeMemoryGB is the maximum memory size during the specified period // If 0, then `ScalingConfig.DefaultMaxSizeMemoryGB` will be used // NOTE: Currently we only support 64GB node for simplicity MaxSizeMemoryGB int `validate:"gte=64,gtefield=MinSizeMemoryGB"` // cron format schedule // default timezone is machine local timezone, // if you want to specify, set TZ= prefix (e.g. `TZ=UTC 0 0 0 0 0`) StartCronSchedule string Duration time.Duration `validate:"gt=0"` }
ScheduledScalingConfig represents scheduled min/max memory max size within the period
Click to show internal directories.
Click to hide internal directories.