queue

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestFunc

type RequestFunc func(client *http.Client, done chan<- RequestResult)

RequestFunc is a function that performs an HTTP request using the provided client, and sends its result to the given result channel.

type RequestQueue

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

func NewRequestQueue

func NewRequestQueue(rps int, burst int) *RequestQueue

NewRequestQueue creates a new rate-limited request queue. `rps` = requests per second, `burst` = burst capacity

func (*RequestQueue) Enqueue

func (q *RequestQueue) Enqueue(job RequestFunc) <-chan RequestResult

Enqueue adds a new request to the queue and returns a result channel.

func (*RequestQueue) Shutdown

func (q *RequestQueue) Shutdown()

Shutdown stops the queue and waits for the worker to finish.

type RequestResult

type RequestResult struct {
	Body []byte
	Err  error
}

RequestResult holds the result of a queued request.

Jump to

Keyboard shortcuts

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