sync

package
v3.3.14 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSlotsAvailable = errors.New("no slots available")

ErrNoSlotsAvailable is returned when WithLimit cannot acquire a slot immediately.

Functions

This section is empty.

Types

type FuseOpLimiter

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

FuseOpLimiter enforces multiple classes of limits, plus an optional global limit.

func NewFuseOpLimiter

func NewFuseOpLimiter(perClass map[FuseOpType]int64, global int64) *FuseOpLimiter

NewFuseOpLimiter creates a new MultiLimiter with the given per-class and global limits. A limit of 0 disables that limit.

func (*FuseOpLimiter) TryWithLimit added in v3.3.11

func (m *FuseOpLimiter) TryWithLimit(ctx context.Context, cl FuseOpType, fn func(context.Context) error) error

TryWithLimit applies the class (and global) limit without blocking. Reentrant-safe: if the context already holds the class token, it won't acquire again. Returns ErrNoSlotsAvailable immediately if slots cannot be acquired.

func (*FuseOpLimiter) WithLimit

func (m *FuseOpLimiter) WithLimit(ctx context.Context, cl FuseOpType, fn func(context.Context) error) error

WithLimit applies the class (and global) limit. Reentrant-safe: if the context already holds the class token, it won't acquire again. This method blocks until slots are available.

type FuseOpType

type FuseOpType uint8

FuseOpType represents the type of operation for limiting purposes.

e.g. upload vs download operations.

const (

	// FuseOpUpload represents upload operations.
	FuseOpUpload FuseOpType

	// FuseOpDownload represents download operations.
	FuseOpDownload

	// FuseOpOther represents other operations. e.g. list, find, delete, etc.
	FuseOpOther
)

Jump to

Keyboard shortcuts

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