generator

package
v0.0.0-...-12a582f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInterval = 5 * time.Second
	DefaultMaxCount = 200
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Handler  Handler
	Interval time.Duration
	MaxCount int
}

Default implementation

func DefaultConfig

func DefaultConfig() Config

type DefaultGenerator

type DefaultGenerator struct {
	Handler        Handler
	Interval       time.Duration
	MaxCount       int
	ProcessedCount int
	// contains filtered or unexported fields
}

Default implementation

func (*DefaultGenerator) Errors

func (d *DefaultGenerator) Errors() chan error

func (*DefaultGenerator) Generate

func (d *DefaultGenerator) Generate()

func (*DefaultGenerator) Start

func (d *DefaultGenerator) Start() chan bool

Start

func (*DefaultGenerator) Stop

func (d *DefaultGenerator) Stop() bool

type Generator

type Generator interface {
	Start() chan bool
	Stop() bool
	Errors() chan error
}

Generator interface if there is a need

func New

func New() Generator

Return a new Generator returning interface with the default handler

func NewBuilder

func NewBuilder(cmd *cobra.Command, h Handler) Generator

NewBuilder builds a cli usage generator, parsing particular flags (constant, max, interval) and building configuration while injecting the command (CMD) specific handler for generating events

This exists to prevent duplication across the various event generator cli commands that will merely implement a unique handler

func NewWitConfig

func NewWitConfig(cfg Config) Generator

Return a new Generator returning interface with an injected handler

func NewWithHandler

func NewWithHandler(h Handler) Generator

Return a new Generator returning interface with an injected handler

type Handler

type Handler func() error

Jump to

Keyboard shortcuts

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