'retry'); } if ('status' === $result['kind'] && 'failed' === $result['status']) { return Akkedli_Connector_State::replace( Akkedli_V2_Binding_State::failed($expected), $expected); } if ('terminal' === $result['kind']) { return Akkedli_Connector_State::replace(Akkedli_V2_Binding_State::failed($expected), $expected); } if ('paused' === $result['kind']) return self::stop($expected); if ('manual' === $result['kind']) { $next = $expected; $next['automatic_stopped'] = true; $next['next_attempt_at'] = 0; return Akkedli_Connector_State::replace($next, $expected); } if (!$automatic) return true; $next = $expected; // attempt_count is the number of consumed offsets, including skipped overdue slots. while ($next['attempt_count'] < count(self::OFFSETS) && $next['poll_started_at'] + self::OFFSETS[$next['attempt_count']] <= $now) { $next['attempt_count']++; } $expired = $next['attempt_count'] >= count(self::OFFSETS) || $now - $next['poll_started_at'] >= 900; $next['automatic_stopped'] = $expired; $next['next_attempt_at'] = $expired ? 0 : $next['poll_started_at'] + self::OFFSETS[$next['attempt_count']]; if (!$expired && isset($result['retry_after']) && is_int($result['retry_after'])) $next['next_attempt_at'] = min($next['poll_started_at'] + 900, max($next['next_attempt_at'], $now + $result['retry_after'])); return Akkedli_Connector_State::replace($next, $expected); } public static function stop(array $expected) { $next = $expected; $next['automatic_stopped'] = true; $next['next_attempt_at'] = 0; return Akkedli_Connector_State::replace($next, $expected); } }