timer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package timer provides timer implementations for Narwhal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockTimer

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

MockTimer is a timer for testing that can be triggered manually.

func NewMockTimer

func NewMockTimer() *MockTimer

NewMockTimer creates a new MockTimer.

func (*MockTimer) C

func (t *MockTimer) C() <-chan struct{}

C returns the timer channel.

func (*MockTimer) Fire

func (t *MockTimer) Fire()

Fire triggers the timer, simulating a timeout. This is the test helper method.

func (*MockTimer) IsStarted

func (t *MockTimer) IsStarted() bool

IsStarted returns true if the timer has been started.

func (*MockTimer) IsStopped

func (t *MockTimer) IsStopped() bool

IsStopped returns true if the timer has been stopped.

func (*MockTimer) Reset

func (t *MockTimer) Reset()

Reset resets the mock timer.

func (*MockTimer) Start

func (t *MockTimer) Start()

Start starts the mock timer.

func (*MockTimer) Stop

func (t *MockTimer) Stop()

Stop stops the mock timer.

type RealTimer

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

RealTimer implements Timer using actual time.

func NewRealTimer

func NewRealTimer(duration time.Duration) *RealTimer

NewRealTimer creates a new RealTimer with the given duration.

func (*RealTimer) C

func (t *RealTimer) C() <-chan struct{}

C returns the timer channel.

func (*RealTimer) Duration

func (t *RealTimer) Duration() time.Duration

Duration returns the timer's configured duration.

func (*RealTimer) Reset

func (t *RealTimer) Reset()

Reset resets the timer.

func (*RealTimer) Start

func (t *RealTimer) Start()

Start starts the timer.

func (*RealTimer) Stop

func (t *RealTimer) Stop()

Stop stops the timer.

type Timer

type Timer interface {
	// Start starts the timer to fire after the configured duration.
	Start()

	// Stop stops the timer, preventing it from firing.
	Stop()

	// Reset resets the timer to fire after the configured duration.
	// If the timer was stopped, this starts it again.
	Reset()

	// C returns the channel that receives when the timer fires.
	C() <-chan struct{}
}

Timer provides timeout management for batch and header creation.

Jump to

Keyboard shortcuts

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