waitpoll

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package waitpoll provides shared polling loops for wait-style tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DurationFunc

type DurationFunc func(seconds int) time.Duration

DurationFunc converts user-facing seconds into the duration used by timers.

type Options

type Options[T any] struct {
	Request         *mcp.CallToolRequest
	IntervalSeconds int
	TimeoutSeconds  int
	FailOnError     *bool
	PollDuration    DurationFunc
	ProgressMessage func(attempt int) string
	Poll            func(context.Context) (T, error)
	Status          func(T) string
	FailureError    func(T) error
}

Options configures a polling loop for one wait-style tool.

type Result

type Result[T any] struct {
	Item        T
	WaitedFor   string
	PollCount   int
	FinalStatus string
	TimedOut    bool
}

Result reports the final item and polling metadata.

func Poll

func Poll[T any](ctx context.Context, opts Options[T]) (Result[T], error)

Poll polls until the item reaches a terminal status, the context is canceled, or the configured timeout expires.

Jump to

Keyboard shortcuts

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