limits

package
v0.0.0-...-e62627f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package limits defines opt-in resource limits shared by one QuickJS runtime.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFetchConcurrencyExceeded     = errors.New("fetch concurrency limit exceeded")
	ErrWebSocketConcurrencyExceeded = errors.New("websocket connection limit exceeded")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	ExecuteTimeout           time.Duration
	MaxFetchConcurrent       int
	MaxFetchResponseBytes    int64
	MaxWebSocketConnections  int
	MaxWebSocketMessageBytes int64
	MaxFilesystemReadBytes   int64
	MaxFilesystemWriteBytes  int64
	MaxPBKDF2Iterations      int
	MaxPBKDF2OutputBytes     int
}

Config configures one QuickJS runtime. Zero values leave the corresponding resource unlimited.

func (Config) Validate

func (c Config) Validate() error

Validate rejects limits that cannot represent an unlimited-or-positive resource policy.

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

Runtime owns counters shared by every API surface in one QuickJS runtime.

func NewRuntime

func NewRuntime(config Config) (*Runtime, error)

NewRuntime validates and copies config before constructing shared counters.

func (*Runtime) AcquireFetch

func (r *Runtime) AcquireFetch() (func(), error)

AcquireFetch reserves one fetch slot until its idempotent release is called.

func (*Runtime) AcquireWebSocket

func (r *Runtime) AcquireWebSocket() (func(), error)

AcquireWebSocket reserves one connection slot until its idempotent release is called.

func (*Runtime) Config

func (r *Runtime) Config() Config

Config returns the immutable resource policy for this runtime.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL