throughput

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(size int) string

FormatSize turns a byte count into a human readable string.

func Listen

func Listen[T any](parent context.Context, sl StreamListener[T], sc StreamConfig) error

Types

type StreamConfig

type StreamConfig struct {
	Name          string
	TickInterval  time.Duration
	ChannelBuffer int
}

func DefaultStreamConfig

func DefaultStreamConfig(name string) StreamConfig

type StreamListener

type StreamListener[T any] interface {
	// Connect indicates how the stream listener should connect and setup its primary stream
	Connect(context.Context) error

	// Produce indicates how to receive a series of messages on the connection
	Produce() ([]T, error)

	// Filter applies to produced items to determine whether they should be counted
	Filter(T) bool

	// Size applies to produced items to indicate its byte size
	Size(T) int

	// OnUpdate is a flexible trigger that can fire on each produced item
	OnUpdate(T)
}

Jump to

Keyboard shortcuts

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