frate

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package frate implements file-based rate limiting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

type Limiter struct {
	Dir string // defaults to "."
	// contains filtered or unexported fields
}

Limiter is a file-based rate limiter. It is not safe for concurrent use.

func (*Limiter) Err

func (l *Limiter) Err() error

Err returns the last error encountered, if any.

func (*Limiter) Errs

func (l *Limiter) Errs() []error

Errs returns all errors encountered, if any.

func (*Limiter) Touch

func (l *Limiter) Touch(name string, d time.Duration) bool

Touch updates the last-accessed time of the named bucket if the time since the current access time is >= d. It returns true if the bucket was touched; false otherwise.

If an error occurs, it is recorded and returned by Err.

func (*Limiter) Touched

func (l *Limiter) Touched() []string

Touched returns the names of the buckets that have been touched successfully. The returned slice is not safe to modify, and is only valid until the next call Touch.

Jump to

Keyboard shortcuts

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