timeout

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package timeout provides a context-based timeout wrapper with Enter-to-skip and Escape/Ctrl+C support via /dev/tty for hardware provider derivation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Secret     []byte
	Err        error
	SkipReason SkipReason
}

Result holds the outcome of a timeout-wrapped provider call.

func Run

func Run(ctx context.Context, d time.Duration, fn func(context.Context) ([]byte, error)) Result

Run calls fn with a context that cancels after the given timeout or when the user presses Enter/Escape on /dev/tty. Ctrl+C sends SIGINT to quit. Returns the result and the skip reason.

When the context is canceled (timeout, skip, or interrupt), Run returns immediately without waiting for fn to complete. The goroutine running fn will eventually finish when the underlying call returns.

type SkipReason

type SkipReason int

SkipReason indicates why a provider was skipped.

const (
	NotSkipped     SkipReason = iota
	SkippedTimeout            // deadline exceeded
	SkippedUser               // user pressed Enter/Escape to skip
)

Jump to

Keyboard shortcuts

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