GithubHelp home page GithubHelp logo

settle's Introduction

Settle

Library which provides a function that waits for something to happen. Usage:

use Keboola\Settle\SettleFactory;
use Psr\Log\NullLogger;

$logger = new NullLogger();
$factory = new SettleFactory($logger);

$settle = $factory->createSettle(maxAttempts: 10, maxAttemptsDelay: 1);
$i = 0;
$settle->settle(
    comparator: fn($v) => $v === 5,
    getCurrentValue: function() use (&$i) {while ($i < 5) {$i++; return $i;}},
);

The settle function expects two callbacks - comparator and getCurrentValue. In a typical scenario, the getCurrentValue checks and returns the result of some asynchronous operation (data loaded, process finished) and the comparator checks that the getCurrentValue result is the expected value. If the expected value is not reached within the specified number of attempts a RuntimeException is thrown.

License

MIT licensed, see LICENSE file.

settle's People

Contributors

erikzigo avatar pepamartinec avatar ondrajodas avatar odinuv avatar

Watchers

Martin Zajíc avatar Roman Pištěk avatar  avatar Vladimír Kriška avatar Ondřej Hlaváček avatar Vojtěch Biberle avatar Tomáš Fejfar avatar Martin Halamíček avatar Miroslav Čillík avatar  avatar Pavel Šuraba avatar  avatar Roman Braciník avatar Pavel Chocholouš avatar Jakub Kotek avatar Martin Vaško avatar Martin Jandl avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.