wait

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PollingWaiter

type PollingWaiter struct {
	// ReadFunc 対象リソースの状態を取得するためのfunc
	//
	// ReadFuncがerrorを返した場合は待ち処理が即時リターンする。非エラーかつ非nilを返した場合のみStateCheckFuncでの判定処理を行う。
	ReadFunc StateReadFunc

	// StateCheckFunc ReadFuncで得たリソースの情報を元に待ちを継続するかの判定を行うためのfunc
	StateCheckFunc StateCheckFunc

	// Timeout タイムアウト
	Timeout time.Duration // タイムアウト

	// Interval ポーリング間隔
	Interval time.Duration
}

PollingWaiter ポーリングでステート変更を検知するWaiter

func (*PollingWaiter) WaitForState

func (w *PollingWaiter) WaitForState(ctx context.Context) (interface{}, error)

WaitForState リソースが指定の状態になるまで待つ

func (*PollingWaiter) WaitForStateAsync

func (w *PollingWaiter) WaitForStateAsync(ctx context.Context) (<-chan interface{}, <-chan interface{}, <-chan error)

WaitForStateAsync リソースが指定の状態になるまで待つ

type StateCheckFunc

type StateCheckFunc func(target interface{}) (complete bool, err error)

StateCheckFunc StateReadFuncで得たリソースの情報を元に待ちを継続するか判定するためのfunc

completeがtrueの場合待ち処理を終了する

func ComposeStateCheckFunc

func ComposeStateCheckFunc(funcs ...StateCheckFunc) StateCheckFunc

ComposeStateCheckFunc 指定のStateCheckFuncを順に適用するするStateCheckFuncを生成する

completeがtrueまたはerrが非nilになったら即時リターンする。

type StateReadFunc

type StateReadFunc func() (state interface{}, err error)

StateReadFunc PollingWaiterにより利用される、対象リソースの状態を取得するためのfunc

type StateWaiter

type StateWaiter interface {
	// WaitForState リソースが指定の状態になるまで待つ
	WaitForState(context.Context) (interface{}, error)
	// WaitForStateAsync リソースが指定の状態になるまで待つ(非同期)
	WaitForStateAsync(context.Context) (completeCh <-chan interface{}, progressCh <-chan interface{}, errorCh <-chan error)
}

StateWaiter リソースの状態が変わるまで待機する

Jump to

Keyboard shortcuts

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