Documentation
¶
Index ¶
- Constants
- Variables
- type CPURateControlType
- type JobLimits
- type JobObject
- func (job *JobObject) Assign(pid uint32) error
- func (job *JobObject) Close() error
- func (job *JobObject) Pids() ([]uint32, error)
- func (job *JobObject) PollNotification() (interface{}, error)
- func (job *JobObject) QueryMemoryStats() (*winapi.JOBOBJECT_MEMORY_USAGE_INFORMATION, error)
- func (job *JobObject) QueryProcessorStats() (*winapi.JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, error)
- func (job *JobObject) QueryStorageStats() (*winapi.JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, error)
- func (job *JobObject) SetCPULimit(rateControlType CPURateControlType, rateControlValue uint32) error
- func (job *JobObject) SetIOLimit(maxBandwidth, maxIOPS int64) error
- func (job *JobObject) SetMemoryLimit(memoryLimitInBytes uint64) error
- func (job *JobObject) SetResourceLimits(limits *JobLimits) error
- func (job *JobObject) Terminate(exitCode uint32) error
- type MsgAllProcessesExited
- type MsgUnimplemented
Constants ¶
const ( CPULimitMin = 1 CPULimitMax = 10000 CPUWeightMin = 1 CPUWeightMax = 9 )
Processor resource controls
Variables ¶
var ( ErrAlreadyClosed = errors.New("the handle has already been closed") ErrNotRegistered = errors.New("job is not registered to receive notifications") )
Functions ¶
This section is empty.
Types ¶
type CPURateControlType ¶
type CPURateControlType uint32
const ( WeightBased CPURateControlType = iota RateBased )
type JobLimits ¶
type JobLimits struct { CPULimit uint32 CPUWeight uint32 MemoryLimitInBytes uint64 MaxIOPS int64 MaxBandwidth int64 }
JobLimits represents the resource constraints that can be applied to a job object.
type JobObject ¶
type JobObject struct {
// contains filtered or unexported fields
}
JobObject is a high level wrapper around a Windows job object. Holds a handle to the job, a queue to receive iocp notifications about the lifecycle of the job and a mutex for synchronized handle access.
func Create ¶
Create creates a job object.
`name` specifies the name of the job object if a named job object is desired. If name is an empty string, the job will not be assigned a name.
`notifications` specifies if the job will be registered to receive notifications. If this is false, `PollNotifications` will return immediately with error `errNotRegistered`.
Returns a JobObject structure and an error if there is one.
func (*JobObject) PollNotification ¶
PollNotification will poll for a job object notification. This call should only be called once per job (ideally in a goroutine loop) and will block if there is not a notification ready. This call will return immediately with error `ErrNotRegistered` if the job was not registered to receive notifications during `Create`. Internally, messages will be queued and there is no worry of messages being dropped.
func (*JobObject) QueryMemoryStats ¶
func (job *JobObject) QueryMemoryStats() (*winapi.JOBOBJECT_MEMORY_USAGE_INFORMATION, error)
QueryMemoryStats gets the memory stats for the job object.
func (*JobObject) QueryProcessorStats ¶
func (job *JobObject) QueryProcessorStats() (*winapi.JOBOBJECT_BASIC_ACCOUNTING_INFORMATION, error)
QueryProcessorStats gets the processor stats for the job object.
func (*JobObject) QueryStorageStats ¶
func (job *JobObject) QueryStorageStats() (*winapi.JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION, error)
QueryStorageStats gets the storage (I/O) stats for the job object.
func (*JobObject) SetCPULimit ¶
func (job *JobObject) SetCPULimit(rateControlType CPURateControlType, rateControlValue uint32) error
SetCPULimit sets the CPU limit specified on the job object.
func (*JobObject) SetIOLimit ¶
SetIOLimit sets the IO limits specified on the job object.
func (*JobObject) SetMemoryLimit ¶
SetMemoryLimit sets the memory limit specified on the job object.
func (*JobObject) SetResourceLimits ¶
SetResourceLimits sets resource limits on the job object (cpu, memory, storage).
type MsgAllProcessesExited ¶
type MsgAllProcessesExited struct{}
MsgAllProcessesExited is a type representing a message that every process in a job has exited.
type MsgUnimplemented ¶
type MsgUnimplemented struct{}
MsgUnimplemented represents a message that we are aware of, but that isn't implemented currently. This should not be treated as an error.