pollers

package
v0.20240425.1225320 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MPL-2.0 Imports: 5 Imported by: 2,655

README

Package: github.com/hashicorp/go-azure-sdk/sdk/client/pollers

This package contains both the components for Pollers, which allow an operation to be continually polled until it's either Completed, Cancelled or Failed.

Since Pollers are specific to the API in question, this package only contains the interface each poller needs to implement.

Specific implementations for each type of API can be found within the package for that API, for example a Poller for Long Running Operations within Azure Resource Manager can be found in github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager.

Documentation

Index

Constants

View Source
const DefaultNumberOfDroppedConnectionsToAllow = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type PollResult

type PollResult struct {
	// HttpResponse is a copy of the HttpResponse returned from the API in the last request.
	HttpResponse *client.Response

	// PollInterval specifies the interval until this poller should be called again.
	PollInterval time.Duration

	// Status specifies the polling status of this resource at the time of the last request.
	Status PollingStatus
}

type Poller

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

func NewPoller

func NewPoller(pollerType PollerType, initialDelayDuration time.Duration, maxNumberOfDroppedConnections int) Poller

func (*Poller) FinalResult

func (p *Poller) FinalResult(model interface{}) error

FinalResult attempts to unmarshal the final result into the provided model model should be a pointer to the type you wish to unmarshal into

func (*Poller) LatestResponse

func (p *Poller) LatestResponse() *client.Response

LatestResponse returns the latest HTTP Response returned when polling

func (*Poller) LatestStatus

func (p *Poller) LatestStatus() PollingStatus

LatestStatus returns the latest status returned when polling

func (*Poller) PollUntilDone

func (p *Poller) PollUntilDone(ctx context.Context) error

PollUntilDone polls until the poller determines that the operation has been completed

type PollerType

type PollerType interface {
	// Poll performs a poll to determine whether the Operation has been Completed/Cancelled or Failed.
	// Behaviourally this method should:
	//   1. Perform a single poll, and assume that it will be called again after the PollInterval
	//      defined within the PollResult.
	//   2. When the operation is still in progress, a PollResult should be returned with the Status
	//      `InProgress` and the next PollInterval.
	//   3. When the operation is Completed, a PollResult should be returned with the Status
	//      `Succeeded`.
	//   4. When the operation is Cancelled a PollingCancelledError should be returned.
	//   5. When the operation Fails a PollingFailedError should be returned.
	Poll(ctx context.Context) (*PollResult, error)
}

PollerType allows custom pollers to be created to determine when a particular Operation has been Completed, Cancelled or Failed.

type PollingCancelledError

type PollingCancelledError struct {
	// HttpResponse is a copy of the HttpResponse returned from the API in the last request.
	HttpResponse *client.Response

	// Message is a custom error message containing more details
	Message string
}

PollingCancelledError defines the that the resource change was cancelled (for example, due to a timeout).

func (PollingCancelledError) Error

func (e PollingCancelledError) Error() string

type PollingDroppedConnectionError

type PollingDroppedConnectionError struct {
	// Message is a custom error message containing more details
	Message string
}

PollingDroppedConnectionError defines there was a dropped connection when polling for the status.

func (PollingDroppedConnectionError) Error

type PollingFailedError

type PollingFailedError struct {
	// HttpResponse is a copy of the HttpResponse returned from the API in the last request.
	HttpResponse *client.Response

	// Message is a custom error message containing more details
	Message string
}

PollingFailedError states that the resource change failed (for example due to a lack of capacity).

func (PollingFailedError) Error

func (e PollingFailedError) Error() string

type PollingStatus

type PollingStatus string
const (
	// PollingStatusCancelled states that the resource change has been cancelled.
	PollingStatusCancelled PollingStatus = "Cancelled"

	// PollingStatusFailed states that the resource change has Failed.
	PollingStatusFailed PollingStatus = "Failed"

	// PollingStatusInProgress states that the resource change is still occurring/in-progress.
	PollingStatusInProgress PollingStatus = "InProgress"

	// PollingStatusSucceeded states that the resource change was successful.
	PollingStatusSucceeded PollingStatus = "Succeeded"

	// PollingStatusUnknown states that the resource change state is unknown/unexpected.
	PollingStatusUnknown PollingStatus = "Unknown"
)

Jump to

Keyboard shortcuts

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