poller

package
v2.16.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package poller implements a poller that can be used to wait for a condition to be met. The poller is designed to be a replacement for the azure-sdk-for-go poller with exponential backoff and an injectable clock. reference: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore@v1.1.1/runtime#Poller .

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PollUntilDoneOptions

type PollUntilDoneOptions struct {
	StartingBackoff time.Duration
	MaxBackoff      time.Duration
	clock.Clock
}

PollUntilDoneOptions provides options for the Poller. Used to specify backoff and clock options.

func NewPollUntilDoneOptions

func NewPollUntilDoneOptions() *PollUntilDoneOptions

NewPollUntilDoneOptions creates a new PollUntilDoneOptions with the default values and a real clock.

type Poller

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

Poller is a poller that can be used to wait for a condition to be met. The poller is designed to be a replacement for the azure-sdk-for-go poller with exponential backoff and an injectable clock. reference: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore@v1.1.1/runtime#Poller .

func New

func New[T any](handler PollingHandler[T]) *Poller[T]

New creates a new Poller.

func (*Poller[T]) Done

func (p *Poller[T]) Done() bool

Done returns true if the condition is met.

func (*Poller[T]) Poll

func (p *Poller[T]) Poll(ctx context.Context) error

Poll polls the handler.

func (*Poller[T]) PollUntilDone

func (p *Poller[T]) PollUntilDone(ctx context.Context, options *PollUntilDoneOptions) (T, error)

PollUntilDone polls the handler until the condition is met or the context is cancelled.

func (*Poller[T]) Result

func (p *Poller[T]) Result(ctx context.Context) (T, error)

Result returns the result of the poller if the condition is met. If the condition is not met, an error is returned.

type PollingHandler

type PollingHandler[T any] interface {
	Done() bool
	Poll(ctx context.Context) error
	Result(ctx context.Context, out *T) error
}

PollingHandler is a handler that can be used to poll for a condition to be met.

Jump to

Keyboard shortcuts

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