Documentation ¶
Index ¶
- func Limit(ctx context.Context, perSecond float64, in <-chan string) <-chan string
- func Ranges(ctx context.Context, ranges []Range, format string, ch chan<- string, ...) error
- func Reader(ctx context.Context, rd io.ReadCloser, ch chan<- string, count chan<- int) (err error)
- type Filter
- type FilterLimit
- type FilterSkip
- type Range
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Limit ¶
Limit limits the number of values per second to the value perSecond. A new goroutine is started, which terminates when in is closed or the context is cancelled.
func Ranges ¶
func Ranges(ctx context.Context, ranges []Range, format string, ch chan<- string, count chan<- int) error
Ranges sends all range values to the channel ch, and the number of items to the channel count. Sending stops and ch and count are closed when an error occurs or the context is cancelled. When format is the empty string, "%d% is used.
Types ¶
type Filter ¶
type Filter interface { // Count corrects the number of total items to test Count(ctx context.Context, in <-chan int) <-chan int // Select filters the items Select(ctx context.Context, in <-chan string) <-chan string }
Filter selects/rejects items received from a producer.
type FilterLimit ¶
type FilterLimit struct {
Max int
}
FilterLimit passes through at most Max values.
type FilterSkip ¶
type FilterSkip struct {
Skip int
}
FilterSkip skips the first n values sent over the channel.
type Range ¶
type Range struct {
First, Last int
}
Range defines a range of values which should be tested.
func ParseRange ¶
ParseRange parses a range from the string s. Valid formats are `n` and `n-m`.