pool

package
v0.0.0-...-19b0ade Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// id is the RPC service ID.
	Id string
	// description of the item.
	Description string
	// priority is the priority of the item.
	Priority uint8
	// amount of request per minute
	RequestsPerMinute uint16
}

Config is the configuration of an pool item.

type Item

type Item struct {
	// Id is the item ID.
	Id string
	// description of the item.
	Description string
	// contains filtered or unexported fields
}

Item defines the item of the pool.

func (*Item) Wait

func (i *Item) Wait(ctx context.Context) error

Wait waits for the rate limiter to allow the next item request.

type Pool

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

Pool is a pool of items.

func NewPool

func NewPool(cfg []Config) *Pool

NewPool creates a new pool.

func (*Pool) GetItem

func (p *Pool) GetItem() Item

GetItem returns the next available item of the pool.

func (*Pool) GetItems

func (p *Pool) GetItems() []Item

GetItems returns the list of items sorted by score and priority. Once there is an event on the item, it must be notified using the method NotifyEvent.

Jump to

Keyboard shortcuts

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