Documentation
¶
Overview ¶
Package protector provides a set of protectors that stop the query services when the resource usage exceeds the limit.
Index ¶
- type Memory
- type Nop
- func (Nop) AcquireResource(_ context.Context, _ uint64) error
- func (Nop) AvailableBytes() int64
- func (Nop) FlagSet() *run.FlagSet
- func (Nop) GetLimit() uint64
- func (Nop) GracefulStop()
- func (Nop) Name() string
- func (Nop) PreRun(context.Context) error
- func (Nop) Serve() run.StopNotify
- func (Nop) ShouldCache(int64) bool
- func (n Nop) State() State
- func (Nop) Validate() error
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Memory ¶
type Memory interface {
AvailableBytes() int64
GetLimit() uint64
AcquireResource(ctx context.Context, size uint64) error
// ShouldCache returns true if the file size is smaller than the threshold.
ShouldCache(fileSize int64) bool
run.PreRunner
run.Config
run.Service
// State returns the current memory pressure state.
State() State
}
Memory is an interface for monitoring and limiting memory usage to prevent OOM.
func NewMemory ¶
func NewMemory(omr observability.MetricsRegistry) Memory
NewMemory creates a new Memory protector.
type Nop ¶ added in v0.9.0
type Nop struct{}
Nop is a no-op implementation of Memory interface for testing.
func (Nop) AcquireResource ¶ added in v0.9.0
AcquireResource always succeeds.
func (Nop) AvailableBytes ¶ added in v0.9.0
AvailableBytes always returns -1 (unlimited).
func (Nop) Serve ¶ added in v0.9.0
func (Nop) Serve() run.StopNotify
Serve returns a closed channel.
func (Nop) ShouldCache ¶ added in v0.9.0
ShouldCache always returns false.
Click to show internal directories.
Click to hide internal directories.