Documentation ¶
Overview ¶
Package limits provides resource limits.
Index ¶
Constants ¶
const ( // CtxLimits is a Context.Value key for a LimitSet. CtxLimits contextID = iota )
const Infinity = ^uint64(0)
Infinity is a constant representing a resource with no limit.
Variables ¶
var FromLinuxResource = map[int]LimitType{ linux.RLIMIT_CPU: CPU, linux.RLIMIT_FSIZE: FileSize, linux.RLIMIT_DATA: Data, linux.RLIMIT_STACK: Stack, linux.RLIMIT_CORE: Core, linux.RLIMIT_RSS: Rss, linux.RLIMIT_NPROC: ProcessCount, linux.RLIMIT_NOFILE: NumberOfFiles, linux.RLIMIT_MEMLOCK: MemoryLocked, linux.RLIMIT_AS: AS, linux.RLIMIT_LOCKS: Locks, linux.RLIMIT_SIGPENDING: SignalsPending, linux.RLIMIT_MSGQUEUE: MessageQueueBytes, linux.RLIMIT_NICE: Nice, linux.RLIMIT_RTPRIO: RealTimePriority, linux.RLIMIT_RTTIME: Rttime, }
FromLinuxResource maps linux resources to sentry LimitTypes.
Functions ¶
Types ¶
type Limit ¶
type Limit struct { // Cur specifies the current limit. Cur uint64 // Max specifies the maximum settable limit. Max uint64 }
Limit specifies a system limit.
+stateify savable
type LimitSet ¶
type LimitSet struct {
// contains filtered or unexported fields
}
LimitSet represents the Limits that correspond to each LimitType.
+stateify savable
func FromContext ¶
FromContext returns the limits that apply to ctx.
func FromContextOrDie ¶
FromContextOrDie returns FromContext(ctx) if the latter is not nil. Otherwise, panic is triggered.
func NewLinuxDistroLimitSet ¶
NewLinuxDistroLimitSet returns a new LimitSet whose values are typical for a booted Linux distro.
Many Linux init systems adjust the default Linux limits to values more expected by the rest of the userspace. NewLinuxDistroLimitSet returns a LimitSet with sensible defaults for applications that aren't starting their own init system.
func NewLinuxLimitSet ¶
NewLinuxLimitSet returns a LimitSet whose values match the default rlimits in Linux.
func (*LimitSet) Get ¶
Get returns the resource limit associated with LimitType t. If no limit is provided, it defaults to an infinite limit.Infinity.
func (*LimitSet) GetCapped ¶
GetCapped returns the current value for the limit, capped as specified.
func (*LimitSet) Set ¶
Set assigns value v to resource of LimitType t and returns the old value. privileged should be true only when either the caller has CAP_SYS_RESOURCE or when creating limits for a new kernel.
func (*LimitSet) SetUnchecked ¶
SetUnchecked assigns value v to resource of LimitType t.