requests

package
v0.0.0-...-511a5e0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package requests implements a queue of pending requests. It is optimised for frequent membership checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

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

Request represents an outgoing request.

func (*Request) Cancel

func (r *Request) Cancel()

Cancel marks a request as cancelled.

func (Request) Cancelled

func (r Request) Cancelled() bool

Cancelled returns true if the request was cancelled.

func (Request) String

func (r Request) String() string

type Requests

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

Requests represents a request queue.

func (*Requests) Cancel

func (rs *Requests) Cancel(index uint32) (bool, bool)

Cancel cancels a request that has been sent out. It returns two booleans: the first one indicates if the request was found, the second one indicates whether a Cancel should be sent out.

func (*Requests) Clear

func (rs *Requests) Clear(both bool, f func(uint32))

Clear cancels all queued request. It calls the given function for all requests that have already been sent out.

func (*Requests) Del

func (rs *Requests) Del(index uint32) (bool, bool, time.Time)

Del deletes a request, whether it was sent out or not.

func (*Requests) DelRequested

func (rs *Requests) DelRequested(index uint32) bool

DelRequested deletes a request only if it has been sent out.

func (*Requests) Dequeue

func (rs *Requests) Dequeue() (request Request, index uint32)

Dequeue returns the next request that should be sent out.

func (*Requests) Enqueue

func (rs *Requests) Enqueue(index uint32) bool

Enqueue enqueues a new request. It returns false if the request is a duplicate.

func (*Requests) EnqueueRequest

func (rs *Requests) EnqueueRequest(r Request)

Enqueue enqueues a request that has been sent out.

func (*Requests) Expire

func (rs *Requests) Expire(t0, t1 time.Time,
	drop func(index uint32),
	cancel func(index uint32)) bool

Expire clears all requests that have been cancelled before time t1 or sent out before time t0.

func (*Requests) Queue

func (rs *Requests) Queue() int

Queue returns the number of requests queued but not sent out.

func (*Requests) Requested

func (rs *Requests) Requested() int

Requested returns the number of requests sent out.

func (*Requests) String

func (rs *Requests) String() string

Jump to

Keyboard shortcuts

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