共用方式為


RetryOperation class

實作重試作業的必要邏輯,例如連線、接收 C2D 訊息、傳送遙測、對應項更新等。

建構函式

RetryOperation(string, RetryPolicy, number)

建立 的執行個體。<xref:azure-iot-common.RetryOperation.>

方法

retry((opCallback: (err?: Error, result?: any, response?: any) => void) => void, (err?: Error, result?: any, response?: any) => void)

如果作業失敗,且重試原則允許它,則會執行作業並重試。

建構函式詳細資料

RetryOperation(string, RetryPolicy, number)

建立 的執行個體。<xref:azure-iot-common.RetryOperation.>

new RetryOperation(name: string, policy: RetryPolicy, maxTimeout: number)

參數

name

string

policy
RetryPolicy

要用於此作業的重試原則,決定「可重試」或「可重試」的錯誤,以及重試的速度。

maxTimeout

number

此作業的逾時上限,之後不會嘗試重試。

方法詳細資料

retry((opCallback: (err?: Error, result?: any, response?: any) => void) => void, (err?: Error, result?: any, response?: any) => void)

如果作業失敗,且重試原則允許它,則會執行作業並重試。

function retry(operation: (opCallback: (err?: Error, result?: any, response?: any) => void) => void, finalCallback: (err?: Error, result?: any, response?: any) => void)

參數

operation

(opCallback: (err?: Error, result?: any, response?: any) => void) => void

要執行的作業。

finalCallback

(err?: Error, result?: any, response?: any) => void

視需要重試之後,以最終錯誤或結果呼叫的回呼。