source

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstSource

type ConstSource[T any] struct {
	// contains filtered or unexported fields
}

ConstSource always returns the same value.

func NewConstSource

func NewConstSource[T any](clk clock.Clock, value T) *ConstSource[T]

NewConstSource creates a source that always returns the given value.

func (*ConstSource[T]) Stats added in v0.3.0

func (s *ConstSource[T]) Stats() SourceStats

Stats returns current source metrics.

func (*ConstSource[T]) Subscribe

func (s *ConstSource[T]) Subscribe() <-chan T

Subscribe returns a channel that receives constant values on each clock tick.

type Publisher

type Publisher[T any] interface {
	Subscribe() <-chan T
	Stats() SourceStats
}

Publisher provides a subscription interface for typed values.

type RandomIntSource

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

RandomIntSource generates random integers within a range [min, max].

func NewRandomIntSource

func NewRandomIntSource(clk clock.Clock, min, max int) *RandomIntSource

NewRandomIntSource creates a source that generates random integers in the inclusive range [min, max]. Uses the global seed registry for deterministic sequences when seeded.

func (*RandomIntSource) Stats added in v0.3.0

func (s *RandomIntSource) Stats() SourceStats

Stats returns current source metrics.

func (*RandomIntSource) Subscribe

func (s *RandomIntSource) Subscribe() <-chan int

Subscribe returns a channel that receives random integers on each clock tick.

type SourceStats added in v0.3.0

type SourceStats struct {
	GenerationCount uint64
	SubscriberCount int
}

SourceStats contains observable metrics for a Source.

Jump to

Keyboard shortcuts

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