PHPackages                             jojo1981/polling - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jojo1981/polling

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jojo1981/polling
================

Polling library for conditionally retry operations based on a result checker.

4.0.0(4mo ago)210.3k↓29.5%1MITPHPPHP ^8.0CI passing

Since Apr 20Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/jojo1981/polling)[ Packagist](https://packagist.org/packages/jojo1981/polling)[ RSS](/packages/jojo1981-polling/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (11)Used By (0)

Polling library for conditionally retry operations based on a result checker.
=============================================================================

[](#polling-library-for-conditionally-retry-operations-based-on-a-result-checker)

[![Build Status](https://github.com/jojo1981/polling/actions/workflows/build.yml/badge.svg)](https://github.com/jojo1981/polling/actions/workflows/build.yml)[![Coverage Status](https://camo.githubusercontent.com/043d7e54dd5dd8d603b8d2a3cb0efd47173336bcf7e3db1fae0da3948dcc9ca1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a6f6a6f313938312f706f6c6c696e672f62616467652e737667)](https://coveralls.io/github/jojo1981/polling)[![Latest Stable Version](https://camo.githubusercontent.com/947152addde81e1ca631bf763971ee0d0fbdadce44b47af522ed5dac60a92a36/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6a6f313938312f706f6c6c696e672f762f737461626c65)](https://packagist.org/packages/jojo1981/polling)[![Total Downloads](https://camo.githubusercontent.com/53677d0cfec87d8436f8eeaf3481a6d49894169927b36dacc7d53660cf67cfe4/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6a6f313938312f706f6c6c696e672f646f776e6c6f616473)](https://packagist.org/packages/jojo1981/polling)[![License](https://camo.githubusercontent.com/7bfd5531f119b267ca83a7910398bac96d69c0abbbb0b23ff26bc0372541893b/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6a6f313938312f706f6c6c696e672f6c6963656e7365)](https://packagist.org/packages/jojo1981/polling)

Author: Joost Nijhuis &lt;&gt;

A simple polling library which retries the poll action as long as the result checker is not returning a success result for a maximum number of times with a given delay in between.

The executor callback can perform any task you want and can return any result you want. The result checker should be able to check whether the result from the executor is successful or not and must return a boolean value. Optionally you can add an exception checker. This can be omitted and be handled in the executor, but for separation of concerns you can split this logic. The delay in microseconds can be given and is by default 10000000 microseconds (10 seconds). The delay will be between the retries. The max poll count can be given and is by default 10. The max poll count is the number of times at maximum the executor will be invoked including the first time. Default arguments for the executor, result checker, exception checker and start polling can be omitted. This can be handy to keep the callback functions pure.

Installation
------------

[](#installation)

### Library

[](#library)

```
git clone https://github.com/jojo1981/polling.git
```

### Composer

[](#composer)

[Install PHP Composer](https://getcomposer.org/doc/00-intro.md)

```
composer require jojo1981/polling
```

### Usage

[](#usage)

```
