Help us shape the future of Go! Take the 2026 Go Developer Survey

refresh

package
v1.7.20 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMinInterval = 4 * time.Second
	DefaultMaxInterval = 1024 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetcher

type Fetcher[T equaler[T]] struct {
	// contains filtered or unexported fields
}

func NewFetcher

func NewFetcher[T equaler[T]](
	fetchFunc func(context.Context) (T, error),
	minInterval time.Duration,
	maxInterval time.Duration,
	consumeFunc func(T) error,
	logger Logger,
) *Fetcher[T]

NewFetcher creates a new Fetcher. If minInterval is 0, it will default to 4 seconds.

func (*Fetcher[T]) Start

func (f *Fetcher[T]) Start(ctx context.Context)

type Logger

type Logger interface {
	Debugf(format string, v ...interface{})
	Printf(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
}

type MockTickProvider

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

MockTickProvider is a mock implementation of the TickProvider interface

func NewMockTickProvider

func NewMockTickProvider() *MockTickProvider

NewMockTickProvider creates a new MockTickProvider

func (*MockTickProvider) C

func (m *MockTickProvider) C() <-chan time.Time

C returns the channel on which ticks are delivered

func (*MockTickProvider) GetCurrentDuration

func (m *MockTickProvider) GetCurrentDuration() time.Duration

func (*MockTickProvider) Reset

func (m *MockTickProvider) Reset(d time.Duration)

func (*MockTickProvider) Stop

func (m *MockTickProvider) Stop()

Stop stops the ticker

func (*MockTickProvider) Tick

func (m *MockTickProvider) Tick()

Tick manually sends a tick to the channel

type TickProvider

type TickProvider interface {
	Stop()
	Reset(d time.Duration)
	C() <-chan time.Time
}

TickProvider defines an interface for a type that provides a channel that ticks at a regular interval

type TimedTickProvider

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

TimedTickProvider wraps a time.Ticker to implement TickProvider

func NewTimedTickProvider

func NewTimedTickProvider(d time.Duration) *TimedTickProvider

NewTimedTickProvider creates a new TimedTickProvider

func (*TimedTickProvider) C

func (tw *TimedTickProvider) C() <-chan time.Time

C returns the ticker's channel

func (*TimedTickProvider) Reset

func (tw *TimedTickProvider) Reset(d time.Duration)

Reset resets the ticker with a new duration

func (*TimedTickProvider) Stop

func (tw *TimedTickProvider) Stop()

Stop stops the ticker

Jump to

Keyboard shortcuts

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