Documentation ¶
Index ¶
Constants ¶
View Source
const ( MemoryLimitEnvFieldName = "GOMEMLIMIT" ProcessLimitEnvFieldName = "GOMAXPROC" MemoryLimitHumanReadableFieldName = "quota.memory.limit" CpuSecondsLimitHumanReadableFieldName = "quota.cpu.limit" )
Variables ¶
View Source
var ( MemoryLimitHumanReadableDefault = os.Getenv(MemoryLimitEnvFieldName) CpuSecondsLimitHumanReadable = os.Getenv(ProcessLimitEnvFieldName) )
View Source
var Component = &app.Component{ Dependencies: app.Components{ logger.Component, configurator.Component, reConfiguration.Component, info.Component, }, Constructor: app.Constructor(func(container container.Container) error { return container.Provides( NewMetric, NewConfig, NewReConfigurationWithConfigurator, func(reConfiguration *ReConfiguration) Quota { return reConfiguration }, ) }), BindFlags: app.BindFlags(func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.MemoryLimitHumanReadable, MemoryLimitHumanReadableFieldName, MemoryLimitHumanReadableDefault, "memory limit") flagSet.StringVar(&config.CpuSecondsLimitHumanReadable, CpuSecondsLimitHumanReadableFieldName, CpuSecondsLimitHumanReadable, "cpu limit") }) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( logger logger.Logger, quota *ReConfiguration, reConfiguration reConfiguration.ReConfiguration, info info.Info, config *Config, ) { reConfiguration.Registration(quota) logger.Info("quota: registration in the reConfigurator") logger.Infof("quota: set memory limit %s", size.FormatBinary(quota.Memory())) debug.SetMemoryLimit(int64(quota.Memory())) logger.Infof("quota: set the total number of processes %d", quota.Processes()) runtime.GOMAXPROCS(int(quota.Processes())) info.Registration("quota", config) }) }), }
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { MemoryLimitHumanReadable string MemoryLimit uint64 CpuSecondsLimitHumanReadable string CpuSecondsLimit uint32 }
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator, appConfig *app.Config, getQuotas GetQuotas) (*Config, error)
type Quota ¶
func NewWithConfigurator ¶
func NewWithConfigurator(config *Config, configurator configurator.Configurator, appConfig *app.Config, metric *Metric) (Quota, error)
type ReConfiguration ¶
type ReConfiguration struct {
// contains filtered or unexported fields
}
func NewReConfiguration ¶
func NewReConfigurationWithConfigurator ¶
func NewReConfigurationWithConfigurator(config *Config, configurator configurator.Configurator, appConfig *app.Config, informer logger.Informer, metric *Metric) (*ReConfiguration, error)
func (*ReConfiguration) Memory ¶
func (reConfiguration *ReConfiguration) Memory() uint64
func (*ReConfiguration) Processes ¶
func (reConfiguration *ReConfiguration) Processes() uint8
func (*ReConfiguration) Quota ¶
func (reConfiguration *ReConfiguration) Quota() Quota
func (*ReConfiguration) ReConfiguration ¶
func (reConfiguration *ReConfiguration) ReConfiguration(configurator configurator.Configurator) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.