pollers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSucceeded  = "Succeeded"
	StatusCanceled   = "Canceled"
	StatusFailed     = "Failed"
	StatusInProgress = "InProgress"
)

the well-known set of LRO status/provisioning state values.

Variables

View Source
var ErrNoBody = errors.New("the response did not contain a body")

ErrNoBody is returned if the response didn't contain a body.

Functions

func ExtractToken added in v1.0.0

func ExtractToken(token string) ([]byte, error)

ExtractToken returns the poller-specific token information from the provided token value.

func Failed

func Failed(s string) bool

Failed returns true if the LRO's state is terminal failure.

func GetJSON added in v1.0.0

func GetJSON(resp *http.Response) (map[string]interface{}, error)

GetJSON reads the response body into a raw JSON object. It returns ErrNoBody if there was no content.

func GetProvisioningState added in v1.0.0

func GetProvisioningState(resp *http.Response) (string, error)

GetProvisioningState returns the LRO's state from the response body. If there is no state in the response body the empty string is returned.

func GetResourceLocation added in v1.0.0

func GetResourceLocation(resp *http.Response) (string, error)

GetResourceLocation returns the LRO's resourceLocation value from the response body. Typically used for Operation-Location flows. If there is no resourceLocation in the response body the empty string is returned.

func GetStatus added in v1.0.0

func GetStatus(resp *http.Response) (string, error)

GetStatus returns the LRO's status from the response body. Typically used for Azure-AsyncOperation flows. If there is no status in the response body the empty string is returned.

func IsTerminalState

func IsTerminalState(s string) bool

IsTerminalState returns true if the LRO's state is terminal.

func IsTokenValid added in v1.0.0

func IsTokenValid[T any](token string) error

IsTokenValid returns an error if the specified token isn't applicable for generic type T.

func IsValidURL

func IsValidURL(s string) bool

IsValidURL verifies that the URL is valid and absolute.

func NewResumeToken added in v1.0.0

func NewResumeToken[TResult, TSource any](from TSource) (string, error)

NewResumeToken creates a resume token from the specified type. An error is returned if the generic type has no name (e.g. struct{}).

func PollHelper added in v1.0.0

func PollHelper(ctx context.Context, endpoint string, pl exported.Pipeline, update func(resp *http.Response) (string, error)) error

PollHelper creates and executes the request, calling update() with the response. If the request fails, the update func is not called. The update func returns the state of the operation for logging purposes or an error if it fails to extract the required state from the response.

func ResultHelper added in v1.0.0

func ResultHelper[T any](resp *http.Response, failed bool, out *T) error

ResultHelper processes the response as success or failure. In the success case, it unmarshals the payload into either a new instance of T or out. In the failure case, it creates an *azcore.Response error from the response.

func StatusCodeValid

func StatusCodeValid(resp *http.Response) bool

returns true if the LRO response contains a valid HTTP status code

func Succeeded added in v1.0.0

func Succeeded(s string) bool

Succeeded returns true if the LRO's state is terminal success.

Types

type FinalStateVia added in v0.23.0

type FinalStateVia string

FinalStateVia is the enumerated type for the possible final-state-via values.

const (
	// FinalStateViaAzureAsyncOp indicates the final payload comes from the Azure-AsyncOperation URL.
	FinalStateViaAzureAsyncOp FinalStateVia = "azure-async-operation"

	// FinalStateViaLocation indicates the final payload comes from the Location URL.
	FinalStateViaLocation FinalStateVia = "location"

	// FinalStateViaOriginalURI indicates the final payload comes from the original URL.
	FinalStateViaOriginalURI FinalStateVia = "original-uri"

	// FinalStateViaOpLocation indicates the final payload comes from the Operation-Location URL.
	FinalStateViaOpLocation FinalStateVia = "operation-location"
)

type NopPoller

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

used if the operation synchronously completed

func NewNopPoller added in v1.0.0

func NewNopPoller[T any](resp *http.Response) (*NopPoller[T], error)

NewNopPoller creates a NopPoller from the provided response. It unmarshals the response body into an instance of T.

func (*NopPoller[T]) Done

func (*NopPoller[T]) Done() bool

func (*NopPoller[T]) Poll added in v1.0.0

func (p *NopPoller[T]) Poll(context.Context) (*http.Response, error)

func (*NopPoller[T]) Result added in v1.0.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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