Documentation ¶
Index ¶
- Constants
- func DecodeID(tk string) (string, string, error)
- func Failed(s string) bool
- func IsTerminalState(s string) bool
- func IsValidURL(s string) bool
- func KindFromToken(pollerID, token string) (string, error)
- func MakeID(pollerID string, kind string) string
- func PollerType(p *Poller) reflect.Type
- func StatusCodeValid(resp *http.Response) bool
- type NopPoller
- type Operation
- type Poller
- func (l *Poller) Done() bool
- func (l *Poller) FinalResponse(ctx context.Context, respType interface{}) (*http.Response, error)
- func (l *Poller) Poll(ctx context.Context) (*http.Response, error)
- func (l *Poller) PollUntilDone(ctx context.Context, freq time.Duration, respType interface{}) (*http.Response, error)
- func (l *Poller) ResumeToken() (string, error)
Constants ¶
const ( StatusSucceeded = "Succeeded" StatusCanceled = "Canceled" StatusFailed = "Failed" StatusInProgress = "InProgress" )
Variables ¶
This section is empty.
Functions ¶
func IsTerminalState ¶
IsTerminalState returns true if the LRO's state is terminal.
func IsValidURL ¶
IsValidURL verifies that the URL is valid and absolute.
func KindFromToken ¶
KindFromToken extracts the poller kind from the provided token. If the pollerID doesn't match what's in the token an error is returned.
func PollerType ¶
PollerType returns the concrete type of the poller (FOR TESTING PURPOSES).
func StatusCodeValid ¶
returns true if the LRO response contains a valid HTTP status code
Types ¶
type NopPoller ¶
type NopPoller struct{}
used if the operation synchronously completed
func (*NopPoller) FinalGetURL ¶
type Operation ¶
type Operation interface { Done() bool Update(resp *http.Response) error FinalGetURL() string URL() string Status() string }
Operation abstracts the differences between concrete poller types.
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller encapsulates state and logic for polling on long-running operations.
func (*Poller) FinalResponse ¶
FinalResponse will perform a final GET request and return the final HTTP response for the polling operation and unmarshall the content of the payload into the respType interface that is provided.
func (*Poller) Poll ¶
Poll sends a polling request to the polling endpoint and returns the response or error.
func (*Poller) PollUntilDone ¶
func (l *Poller) PollUntilDone(ctx context.Context, freq time.Duration, respType interface{}) (*http.Response, error)
PollUntilDone will handle the entire span of the polling operation until a terminal state is reached, then return the final HTTP response for the polling operation and unmarshal the content of the payload into the respType interface that is provided. freq - the time to wait between intervals in absence of a Retry-After header. Minimum is one second.
func (*Poller) ResumeToken ¶
ResumeToken returns a token string that can be used to resume a poller that has not yet reached a terminal state.